{{sum}}
<input bindinput="numbera" value="{{numberA}}"></input>
<input bindinput="numberb" value="{{numberB}}"></input>
Component({
properties: {
testData1: Number,
testData2: String,
},
data: {
sum: 10
},
methods: {
onLoad: function (options) {
this.setData({
numberA: Math.random() * 10,
numberB: Math.random()
})
},
numbera(e){
this.setData({
numberA: e.detail.value
})
},
numberb(e) {
this.setData({
numberB: e.detail.value
})
}
},
abservers: {
'numberA, numberB': function (numberA, numberB) {
this.setData({
sum: numberA + numberB
})
}
}
})
这个num都不带改变一下的。求大佬指正一下哦