Skip to content

Commit

Permalink
fix: plugin injects are only available in store actions (#460)
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Aug 4, 2020
1 parent a89b44b commit 7c134ba
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions content/en/guides/directory-structure/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -261,18 +261,18 @@ export default {
}
```

Now `$hello(msg)` can be used from `context`, via `this` in Vue instances and via `this` in store `actions`/`mutations`.
Now `$hello` service can be accessed from `context` and `this` in pages, components, plugins, and store actions.

```js{}[example-component.vue]
export default {
mounted() {
this.$hello('mounted')
// will console.log 'Hello mounted!'
},
asyncData(context) {
context.$hello('asyncData')
asyncData({ app, $hello }) {
$hello('asyncData')
// If using Nuxt <= 2.12, use 👇
context.app.$hello('asyncData')
app.$hello('asyncData')
}
}
```
Expand All @@ -282,13 +282,6 @@ export const state = () => ({
someValue: ''
})
export const mutations = {
changeSomeValue(state, newValue) {
this.$hello('store mutation')
state.someValue = newValue
}
}
export const actions = {
setSomeValueToWhatever({ commit }) {
this.$hello('store action')
Expand Down

0 comments on commit 7c134ba

Please sign in to comment.