在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    无    在组件实例进入页面节点树时执行    是组件的生命周期

0
0

纯正商业级微信小程序应用实战,全方位小程序特性讲解

真实数据的高质量小程序项目,学会直接工作

4782 学习 · 2125 问题

查看课程