Page({
updateByPath(e) {
console.log('by path:',JSON.stringify(e.currentTarget.dataset))
this.setData({
'style.count': ++this.data.style.count
})
},
updateByObject(e) {
console.log('by object:',JSON.stringify(e.currentTarget.dataset))
this.setData({
'style': {
count: ++this.data.style.count
}
})
},
data: {
style: {
count: 1
}
}
})
u
输出日志
by path: {"styleObj":{"count":1},"styleStr":"{\"count\":1}"}
by path: {"styleObj":{"count":2},"styleStr":"{\"count\":1}"}
by path: {"styleObj":{"count":3},"styleStr":"{\"count\":1}"}
by path: {"styleObj":{"count":4},"styleStr":"{\"count\":1}"}
by path: {"styleObj":{"count":5},"styleStr":"{\"count\":1}"}
by path: {"styleObj":{"count":6},"styleStr":"{\"count\":1}"}
## by object
by object: {"styleObj":{"count":7},"styleStr":"{\"count\":1}"}
by object: {"styleObj":{"count":8},"styleStr":"{\"count\":8}"}
by object: {"styleObj":{"count":9},"styleStr":"{\"count\":9}"}
by object: {"styleObj":{"count":10},"styleStr":"{\"count\":10}"}
by object: {"styleObj":{"count":11},"styleStr":"{\"count\":11}"}