我有一个vue.js应用程序,在其中使用component
标记和:is="currentView"
更改活动视图的方法。我有一个“状态机”,它根据某些业务逻辑来跟踪从一个组件到另一个组件的有效转换。有时,这会告诉vue实例,其新值currentView
与旧值相同。如果发生这种情况,该组件将不会重新加载。有什么办法可以强制组件重新加载,即使视图是相同的?那就是我想重新加载数据,并执行生命周期挂钩。
这似乎可以解决问题,但是如何使视图闪烁,有什么办法可以避免这种情况?
const oldView = this.currentView
this.currentView = engine.advance()
if(this.currentView == oldView) {
//force reload!
this.currentView = ''
this.$nextTick(function () {
this.currentView = oldView
})
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句