基础库版本 2.11.2
部分代码如下:
drawing:function(e){
var that = this;
console.log(e);
if(that.data.drawing){
that.data.polygon.push(that.data.example);
that.setData({
drawing:false,
polygon:that.data.polygon
})
}else{
that.data.example['points']=[];
that.data.example['id']++;
that.setData({
drawing:true
})
}
},
这是一个按钮事件,polygon被 加值后,在下次开启加值时,会将之前加的值替换,但对原本的值无影响,即几次push后,所有push的值都会变成最后一次push的值
drawing:function(e){ var that = this; console.log(e); if(that.data.drawing){ that.data.polygon.push(Object.assign({}, that.data.example)) // 或者 that.data.polygon.push(JSON.parse(JSON.stringify(that.data.example that.setData({ drawing:false, polygon:that.data.polygon }) }else{ that.data.example['points']=[]; that.data.example['id']++; that.setData({ drawing:true }) } },