【发布时间】:2019-05-19 07:06:16
【问题描述】:
Vue 新手。
使用vue-property-decorator & 也尝试过vue-class-component。
根据 github (https://github.com/kaorun343/vue-property-decorator),data 对象在类中被明确声明,例如ecosystem:
import {Component, Vue} from 'vue-property-decorator';
@Component({
components: {}
})
export default class HelloWorld extends Vue {
ecosystem: [
{
text: 'vuetify-loader',
href: 'https://github.com/vuetifyjs/vuetify-loader'
},
{
text: 'github',
href: 'https://github.com/vuetifyjs/vuetify'
},
{
text: 'awesome-vuetify',
href: 'https://github.com/vuetifyjs/awesome-vuetify'
}
]
}
而不是
data() {
return {
ecosystem: ['bla', 'bla', 'bla']
}
}
但是当我尝试使用它时,得到错误Property or method "ecosystem" is not defined on the instance but referenced during render.
打电话给
created() {
console.log(this.ecosystem)
}
也返回undefined
我错过了什么?
【问题讨论】:
标签: typescript vue.js vuejs2