// pages/index1/index1.js Page({ num1:0, num2:0, num1Input: function (e) { this.num1 = Number (e.detail.value) }, num2Input: function (e) { this.num2 = Number (e.detail.value) }, data: { result:'' }, compare: function(){ var str='' if (this.num1 > this.num2){ str='第1个数大' }else if(this.num1 < this.num2){ str='第2个数大' }else { str='两数相等' } this.setData({ result:str }) }, /** * 生命周期函数--监听页面加载 */ onLoad(options) { }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady() { }, /** * 生命周期函数--监听页面显示 */ onShow() { }, /** * 生命周期函数--监听页面隐藏 */ onHide() { }, /** * 生命周期函数--监听页面卸载 */ onUnload() { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh() { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom() { }, /** * 用户点击右上角分享 */ onShareAppMessage() { } })