Skip to content

Commit be6ab0d

Browse files
committed
add console.log example to demo global mixins
1 parent 13120b4 commit be6ab0d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/v2/guide/composition.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,16 @@ You can also apply a mixin globally, but do this with caution!
313313

314314
<p class="tip">Global mixins affect <strong>every</strong> Vue instance and component, including third-party components.</p>
315315

316+
For example, the code below defines a mixin that will log the creation of _every_ component instance in our app.
317+
318+
``` js
319+
Vue.mixin({
320+
created: function () {
321+
console.log('A component was just created!')
322+
}
323+
})
324+
```
325+
316326
One appropriate use case, however, is to inject processing logic for custom options, such as in the [VueFire plugin](https://github.com/vuejs/vuefire#usage):
317327

318328
``` js

0 commit comments

Comments
 (0)