请教代码的意思
来源:7-9 ES6 const常量
小巧的蜗牛
2018-10-30
switchChange(e) {
const { model } = e.currentTarget.dataset
this.setData({
[model]: e.detail.value,
})
},请问老师,const { model }这个代码是解构赋值吗?是e.currentTarget.dataset的数据中有变量model;
那么,【model】 中括号的又是什么意思?
写回答
1回答
-
Dmhb
2018-10-31
这个是对象解构赋值。只要左边的变量名是右边属性中的其中一个就可以。如果是数组解构,就需要对应顺序。对象中的键如果是变量,需要用[]包裹起来,如[model]
20
相似问题