Vue.js 如何在NuxtJS中上下文可用时立即挂接?
在NuxtJS应用程序(Vue.js 如何在NuxtJS中上下文可用时立即挂接?,vue.js,nuxt.js,hook,Vue.js,Nuxt.js,Hook,在NuxtJS应用程序(ssr:true,target:'static')中,我需要在浏览器中呈现页面时执行一个方法。 细节:我想改变颜色,但我想防止白色闪光 我试过: mounted() { this.changeColor(); }, created() { this.changeColor(); }, …但问题是,当颜色改变时,页面内容已经显示…它会闪烁!(与beforeMount()相同 …我试过: mounted() { this.changeColor()
ssr:true,target:'static'
)中,我需要在浏览器中呈现页面时执行一个方法。
细节:我想改变颜色,但我想防止白色闪光
我试过:
mounted() {
this.changeColor();
},
created() {
this.changeColor();
},
…但问题是,当颜色改变时,页面内容已经显示…它会闪烁!(与beforeMount()相同
…我试过:
mounted() {
this.changeColor();
},
created() {
this.changeColor();
},
…问题是它什么也不做,因为此时不存在this.changeColor()
如何做到这一点?我会尝试在组件的上下文之外使changeColor
成为静态的(这将包括删除对组件道具/数据的任何依赖),以便可以随时调用它。如果你提供复制品的链接,我可能会提供更好的解决方案。