收藏
回答

超级菜鸟问page not found handle not found


每一个js文件 都用page()了,然后bindAdd的function也做了,可是计算按钮只能显示不能用。这是怎么回事?


index.js:

page ({

data: {

num1: "",  //save added number

num2: "",  //save add number

result: "" //save the result

},

//calc button click event

bindAdd: function (e) {

var r = this.data.num1 * 1 + this.data.num2 * 1; //add two number

this.setData({

result: r //update the result to varible

});

},

//added number event

bindinput1: function (e) {

var n = e.detail.value;

if (!isNaN(n)) //input number only

{

this.setData({

num1: n //update the added number

});

}

},

//add number event

bindinput2: function (e) {

var n = e.detail.value;

if (!isNaN(n)) //input number only

{

this.setData({

num2: n //update the add number

});

}

}

})


index.json:


{

"navigationBarBackgroundColor": "#00ff00",

"navigationBarTitleText": "加法计算器",

"navigationBarTextStyle": "white"

}


index.wxml:


<view class ="content">

<view class="section_title">被加数</view>

<slider min="0" max="1000" bindchange='bindInput1' show-value />


<view class="section_title">加数</view>

<slider min="0" max="1000" bindchange="bindInput2" show-value />


<button type="primary" bindtap="bindAdd" >计算</button>

<view class="section_title">结果</view>


<view>{{result}}</view>

</view>


index.wxss:


.container{

justify-content: flex-start;

padding: 30px 0;

}


.container input{

background-color: #eee;

border-radius: 3px;

text-align: left;

width: 720rpx;

height: 100rpx;

line-height: 100rpx;

margin: 20rpx;

}


.container button{

width: 80%;

}


.content {

margin: 40rpx;

}


.content button{

width: 80%;

}


view, button, slider{

margin: 40rpx 0;

}



app.json:


{

"pages": [

"pages/index/index",

"pages/logs/logs",

"pages/button/button"

],

"window": {

"backgroundTextStyle": "light",

"navigationBarBackgroundColor": "#fff",

"navigationBarTitleText": "WeChat",

"navigationBarTextStyle": "black"

},

"sitemapLocation": "sitemap.json"

}


最后一次编辑于  06-08
回答关注问题邀请回答
收藏

2 个回答

  • \
    \
    06-09

    var r = this.data.num1 * 1 + this.data.num2 * 1//add two number

    这行看看有输出吗,

    console.log(r)试试

    06-09
    赞同 1
    回复 2
    • Cuiqian Chen
      Cuiqian Chen
      06-09

      试了 根本就没读到这个页面


      page({

      data: {

      num1: "",  //save added number

      num2: "",  //save add number

      result: "" //save the result

      },

      //calc button click event

      bindAdd: function (e) {

      var r = this.data.num1*1 + this.data.num2*1 ;

      //add two number

      console.log(r);

      this.setData({

      result: r //update the result to varible

      });


      },

      //added number event

      bindinput1: function (e) {

      var n = e.detail.value;

      if (!isNaN(n)) //input number only

      {

      this.setData({

      num1: n //update the added number

      });

      }

      },

      //add number event

      bindinput2: function (e) {

      var n = e.detail.value;

      if (!isNaN(n)) //input number only

      {

      this.setData({

      num2: n //update the add number

      });

      }

      }

      })




      06-09
      回复
    • Cuiqian Chen
      Cuiqian Chen
      06-09


      06-09
      回复
  • Cuiqian Chen
    Cuiqian Chen
    06-09

    谢谢 搞定了 哎 page=>Page


    06-09
    赞同
    回复 2
    • \
      \
      06-10

      居然是大小写QWQ

      06-10
      回复
    • Cuiqian Chen
      Cuiqian Chen
      06-10回复\

      哈哈 是啊 好多年 没coding了,所以闹了个大笑话。 谢谢🙏。

      06-10
      回复