在data上设置了year和month但是 console.log(this.data.year)显示undefined
来源:8-10 组件的data与properties的“奇怪”现象

慕工程6594033
2020-01-29
/**
- 组件的初始数据
*/
data: {
year:Number,
month:String
},
/**
- 生命周期函数
*/
attached:function(){
console.log(this.properties)
console.log(this.data.year)
},
打印结果 year和month是undefined
写回答
1回答
-
慕娘3306793
2020-01-30
你再测一下this.year能不能打印出来
且 attached 无 在组件实例进入页面节点树时执行 是组件的生命周期
00
相似问题
关于自定义设置样式
回答 2
获得服务器数据后无法正常绑定到data
回答 2