Warm tip: This article is reproduced from stackoverflow.com, please click
vue.js

Vue instance per component over single instance

发布于 2020-03-29 20:59:53

due to the structure of our websites we currently are unable to create one main app instance, as there is too much HTML within this.

So instead we are currently looking for the class of app and then creating a new Vue instance per component, which isn't great for communicating between components but it's our current work around.

We are working to create a new structure to support just one overall app. However, just wondering if creating a new instance of Vue for each component is bad for browser performance over having just one instance with the component inside this?

Questioner
Martyn Ball
Viewed
67
Sapnesh Naik 2020-01-31 18:19

Short answer: No

There won’t be any performance difference between an app that uses a root Vue component with child components and an app that uses multiple root Vue components.

All components are still just Vue instances - so it isn’t any different. The only difference is the organization and usage of the instances.