超级菜鸟问page not found handle not found
发布于 6 年前 作者 yong08 8421 次浏览 来自 问答

每一个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”

}

2 回复

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

这行看看有输出吗,

console.log®试试

谢谢 搞定了 哎 page=>Page

回到顶部