Skip to content

Commit 2b66eb0

Browse files
committed
docs: Add $axe methods in README
1 parent ce84ad7 commit 2b66eb0

File tree

1 file changed

+33
-2
lines changed

1 file changed

+33
-2
lines changed

Diff for: README.md

+33-2
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ if (process.env.NODE_ENV !== 'production') {
2323
Vue.use(VueAxe)
2424
}
2525
```
26-
### Configuration
26+
## Configuration
2727
| Key | Type | Description | Default
2828
| ---------------------- | -------- |-------------------------------------------------------------- | -----------
2929
| `clearConsoleOnUpdate` | Boolean | Clears the console each time `vue-axe` runs | `false`
@@ -34,7 +34,7 @@ if (process.env.NODE_ENV !== 'production') {
3434
| `style` | Object | Customize style for console logs. | [See default style](https://github.com/vue-a11y/vue-axe/blob/master/src/index.js#L22)
3535
| `plugins` | Array | Register Axe plugins. [Axe docs: Plugins](https://github.com/dequelabs/axe-core/blob/master/doc/plugins.md)
3636

37-
#### Custom Result Handler
37+
### Custom Result Handler
3838

3939
The `customResultHandler` config property expects a callback like the `axe.run()` callback ([see documentation](https://github.com/dequelabs/axe-core/blob/master/doc/API.md#parameters-axerun)). It will be triggered after each call to `axe.run()`.
4040

@@ -52,6 +52,37 @@ if (process.env.NODE_ENV !== 'production') {
5252
}
5353
```
5454

55+
### Run axe manually `$axe.run({ clearConsole: Boolean, element: Document | HTMLElement })`
56+
The `$axe` is available on the property injected into the Vue instance, so it is available everywhere in your application. With it it is possible to execute the `$axe.run` method to check manually your document or any desired HTMLElement.
57+
58+
```vue
59+
<script>
60+
//...
61+
methods: {
62+
axeRun() {
63+
this.$axe.run({
64+
clearConsole: false,
65+
element: this.$el // e.g. document, document.querySelector('.selector'), ...
66+
})
67+
}
68+
}
69+
</script>
70+
```
71+
72+
### Running custom axe plugins
73+
Learn more about [axe plugin](https://github.com/dequelabs/axe-core/blob/master/doc/plugins.md)
74+
75+
```vue
76+
<script>
77+
//...
78+
methods: {
79+
handle () {
80+
this.$axe.plugins.myPlugin.run()
81+
}
82+
}
83+
</script>
84+
```
85+
5586
## Install in Nuxt.js
5687
Create plugin file `plugins/axe.js`
5788
```javascript

0 commit comments

Comments
 (0)