#菜鸟提问,请问按钮加减怎么才能同步?

小程序 文章 2021-03-07 18:41 347 0 全屏看文

AI助手支持GPT4.0

#菜鸟提问,请问按钮加减怎么才能同步?#Rookie asks, how can the button addition and subtraction be synchronized?

#菜鸟提问,请问按钮加减怎么才能同步?

我制作一个按钮加减对数据库一项数据进行加或减,但是因为写在input里按一下减按钮数据才会出现在input里,这时此数据已经减1 input里显示的数据还是刚刚从数据库拿出来的数据,如果这时按加按钮,哪input里显示的数据是刚才减1的数据运算代码已经贴在楼下

I make a button to add or subtract a data item in the database. However, because it is written in input and pressed the subtract button, the data will appear in input. At this time, the data has been subtracted by 1. The data displayed in input is still the data just taken from the database. If I press the Add button at this time, the data displayed in input is the data subtracted by 1 just now, and the operation code has been pasted downstairs

回答:

惜颜【普卡会员】晨风:让我什么啊!你咋不说话啊!我等你说话呢
Sisam:

应该是input的问题

2031:
onNumberDec: function() {  console.log('减');  var newNumber = this.data.data[0].number --;  this.setData({    number:newNumber  });  if(newNumber == 1)  {    wx.showToast({title:'最后一次',  icon:'none'})  }  console.log(this.data.data[0].number);},//按钮加法运算onNumberInc:function() {  console.log('加');  if(this.data.data[0].number == 0)  {    this.data.data[0].number++  }  var newNumber = this.data.data[0].number++;    this.setData({    number:newNumber  });  console.log(this.data.data[0].number);}

-EOF-

AI助手支持GPT4.0