/*此处省略若干行代码*/
let UserArray = [];
/*此处省略若干行代码*/
Page({
data: {
/*此处省略若干行代码*/
userarray: UserArray,
},
/*此处省略若干行代码*/
Func:function(){
/*此处省略若干行代码*/
userinfotmp = {
nickname: res.content,
hour: options.value1,
minute: options.value2,
second: options.value3,
userid: id
};
/*此处省略若干行代码*/
this.setData({
userarray: this.data.userarray.push(userinfotmp)
});
/*此处省略若干行代码*/
}
/*此处省略若干行代码*/
})
请问this.setData中怎样用push给数组赋值?上述代码中
userarray: this.data.userarray.push(userinfotmp)
的写法是否正确?如果错误,应该怎么写?
this.data.userarray.push(userinfotmp) this.setData({ userarray: this.data.userarray });
看起来没毛病,就这样了