You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+54-37Lines changed: 54 additions & 37 deletions
Original file line number
Diff line number
Diff line change
@@ -5,12 +5,12 @@ Accessibility auditing for Vue.js applications by running [dequelabs/axe-core](h
5
5
## Install package
6
6
#### NPM
7
7
```shell
8
-
npm install -D vue-axe
8
+
npm install -D axe-core vue-axe
9
9
```
10
10
11
11
#### Yarn
12
12
```shell
13
-
yarn add -D vue-axe
13
+
yarn add -D axe-core vue-axe
14
14
```
15
15
---
16
16
@@ -20,27 +20,21 @@ import Vue from 'vue'
20
20
21
21
if (process.env.NODE_ENV!=='production') {
22
22
constVueAxe=require('vue-axe')
23
-
Vue.use(VueAxe, {
24
-
config: {
25
-
// ...
26
-
rules: [
27
-
{ id:'heading-order', enabled:true },
28
-
{ id:'label-title-only', enabled:true },
29
-
// and more
30
-
]
31
-
}
32
-
})
23
+
Vue.use(VueAxe)
33
24
}
34
25
```
35
-
#### Configuration
36
-
|Key|Description|Default|Required|
37
-
|---|---|---|---|
38
-
|`clearConsoleOnUpdate`|Clears the console each time `vue-axe` runs|`true`|`false`|
39
-
|`customResultHandler`|Handle the results from an `axe.run()`. This may be needed for automated tests.|`undefined`|`false`|
40
-
|`config`|Provide your Axe-core configuration: https://github.com/dequelabs/axe-core/blob/master/doc/API.md#api-name-axeconfigure||`false`|
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()`.
46
40
@@ -58,18 +52,45 @@ if (process.env.NODE_ENV !== 'production') {
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
+
61
86
## Install in Nuxt.js
62
87
Create plugin file `plugins/axe.js`
63
88
```javascript
64
89
importVuefrom'vue'
65
90
66
91
if (process.env.NODE_ENV!=='production') {
67
92
constVueAxe=require('vue-axe')
68
-
Vue.use(VueAxe, {
69
-
config: {
70
-
// your configuration data
71
-
}
72
-
})
93
+
Vue.use(VueAxe)
73
94
}
74
95
75
96
```
@@ -78,32 +99,27 @@ In config file `nuxt.config.js`
0 commit comments