在首页引入组件自定义组件my-test,data中声明变量title为hello,并在onLoad中将title赋值为world。在组件my-test中console.log结果却为hello,将title渲染在组件上结果却为world

1***@qq.com
- 发布:2023-09-27 18:20
- 更新:2023-09-28 10:00
- 阅读:129



爱豆豆 - 办法总比困难多
在子组件的mounted中使用$nextTick 试试
mounted() {
this.$nextTick(() => {
console.log(this.title)
})
},
1***@qq.com (作者)
也不行,还是一样的结果
2023-09-28 10:07
1***@qq.com (作者)
设置setTimeout延迟100毫秒后才是修改后的值
2023-09-28 10:09