[Vue warn]: Avoid adding reactive properties to a Vue instance or its root $data at runtime - declare it upfront in the data option.
在这里插入图片描述

报错原因:this.$set() 中传入的数据有问题

如:
this.$set(this, endTime, ‘2021-11-17’) 这是给vue组件中的endTime字段赋值,但是andTime数据类型是ts中的any,相当于vue组件中的data没有定义endTime这个字段,就会报错

// 报错代码
this.testObj = {
	name: 'test'
}
this.$set(this.testObj, 'noPropertyName', value)

正确的格式:
在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐