[Vuejs]-When using a Vue component multiple times in a single page application is the javascript loaded multiple times?

3👍

The component’s lifecycle callbacks are invoked in each component instance. If, for example, the created() callback contained a console.log('hello world'), and you’ve added three of those components to the document, you would see three logs in the console (one from each instance).

On the other hand, event listeners (such as button-click handlers) would only be invoked in the instance from which the event occurred. Say, your component contained a button that had a click-event handler calling console.log(). Clicking the button in one component triggers the handler only in that component, and not other instances of the component.

demo

👤tony19

Leave a comment