思路
一般都是對(duì)象中的屬性或者對(duì)象里的方法
在data中將對(duì)象設(shè)置為空畜隶,在created生命周期中再對(duì)此對(duì)象賦值
代碼
data () {
return {
name: 'lee',
option: {}
}
},
created () {
let that = this
this.option = {
name: that.name,
getName: function () {
that.getName()
}
}
},
methods: {
getName () {
console.log(this.name)
}
}