Skip to content

Commit

Permalink
docs: clarify that mixin flag should be unique (#1243)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Roe <[email protected]>
  • Loading branch information
2 people authored and ImgBotApp committed Jan 10, 2023
1 parent f09eead commit 7dd1ac0
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions content/en/guides/directory-structure/plugins.md
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,10 @@ export default {
Global mixins can be easily added with Nuxt plugins but can cause trouble and memory leaks when not handled correctly. Whenever you add a global mixin to your application, you should use a flag to avoid registering it multiple times:

```js{}[plugins/my-mixin-plugin.js]
import Vue from "vue"
// Make sure to pick a unique name for the flag
// so it won't conflict with any other mixin.
if (!Vue.__my_mixin__) {
Vue.__my_mixin__ = true
Vue.mixin({ ... }) // Set up your mixin then
Expand Down

0 comments on commit 7dd1ac0

Please sign in to comment.