Component `mounted` fires twice on page load

后端 未结 1 892
南旧
南旧 2021-02-14 00:57

I have a very weird error where on page load a components mounted and beforeMount fire/run twice? Each of my components represents a page, so when I lo

相关标签:
1条回答
  • 2021-02-14 01:24

    I had (have) a similar issue. I'm not 100% sure about this, but I think the issue may be caused by vuex. Vuex has it's own internal instance of Vue (created here in the resetStoreVM() function called in the constructor()). My suspicion is that this internal instance of Vue causes some components to be re-created, which in turn triggers the lifecycle events for those components to fire more than once.

    If not in vuex, is it possible that you're creating more than one instance of Vue (i.e. new Vue({})) in your app? Alternatively, is there some code that is causing your primary Vue instance or the Contact component to be initialized more than once? That's all I can think of that might cause this.

    0 讨论(0)
提交回复
热议问题