1

I just create new vue app with default webpack template.

vue init webpack test

and created a basic plugin, following is my plugin code.

export default {
    install(Vue, defaultOptions = {}) {

        Vue.mixin({
            mounted(){
                console.log('myplugin mixin mounted')
            }
        })
    }
}

When I import it in main.js, in the console, its print 3 times. Anyone know why?

0

1 Answer 1

1

With the out of the box webpack template your console.log will print once for the instantiated Vue, once for the App.vue, and then once for the Hello component.

This is because you have defined a global mixin with a mounted handler, which will execute for each Vue and component that is mounted.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.