自定义组件component不支持es6解构赋值
发布于 7 年前 作者 yong62 8601 次浏览 来自 问答

发现在自定义组件中,凡是用解构赋值对变量赋值,对这个变量进行修改不会影响原来的数据。如上图,

properties:{

    calendar:{

        type:Object,

        value:{

            currentType :‘start’,

        }

    }

}

test:(){

    let { calendar } = that.properties;

    let { currentType } = calendar;

    currentType = ‘end’;

    this.setData({

        calendar

    })

}

最秀calendar下的currentType的并不会被修改;

最后附上代码片段:https://developers.weixin.qq.com/s/eLcxMom47Kdx

回到顶部