这个程序,num1 和 num2 的值总是0 ,为什么?
发布于 5 年前 作者 juan89 7904 次浏览 来自 问答

   */

data: {

   

  

result:''

      },


      num1:0,

      num2:0,

      number1change: function(e){

        this.num1=Number(e.detail.value)

        console.log ('第一个数是'+this.num1)},

    number2change: function(e){

          this.num2=Number(e.detail.value)

          console.log ('第二个数是'+this.num2)

    },



compare: function() {



  var str='两个数相等'

if (this.num1>this.num2{

str='第一个数大'

}else if (this.num1<this.num2)

{str='第二个数大'}

this.setData({result: str})

},


  /**

   * 生命周期函数--监听页面加载

   */

  onLoad: function (options) {


this.number1change.apply

this.number2change.apply


    console.log("显示加载")


    console.log(this.num1)

  },


  /**

   * 生命周期函数--监听页面初次渲染完成

   */

  onReady: function () {

    console.log("页面完成")

  },


  /**

   * 生命周期函数--监听页面显示

   */

  onShow: function () {

    console.log("页面显示")

  },


  /**

   * 生命周期函数--监听页面隐藏

   */

  onHide: function () {


  },


这个程序,num1 和 num2 的值总是0 , 请高手指点

回到顶部