export default class Test extends Vue { t = "测试" created() { console.log(this.$options.data()) //Error in created hook: "TypeError: Cannot read property 'props' of undefined" console.log(this.$options.data.call(this)) //{} call的话 返回的是空对象,没有t } }
放到普通的js版的vue 就没问题~~ 求大佬们帮助~万分感谢~
重置的话使用
Object.assign(this.$data, this.$options.data.call(this)) Object.assign(this.$data.target, this.$options.data.call(this).target)
vue-class-component对data做了包裹,导致this.$options.data没有返回我们想要的值
2.1m questions
2.1m answers
60 comments
56.6k users