微信小程序 setData
Page({
/**
* 页面的初始数据
*/
data: {
user:{id:0,name:‘2‘},
userArr:[{id:0,name:‘2‘}]
}
...
});
赋值user.name = ‘test‘
赋值userArr[0].name = ‘test‘
let that = this
that.setData({
‘user.name‘:‘test‘,
‘userArr[0].name‘:‘test‘
});
这样就完成了赋值。
官方:
https://developers.weixin.qq.com/miniprogram/dev/reference/api/Page.html#Page.prototype.setData(Object%20data,%20Function%20callback)
微信小程序 setData
原文:https://www.cnblogs.com/jiduoduo/p/14776373.html