First, the size of a digital comparison (results are shown in the second page)
Ideas (just say here that the back-end): look at the front-end code (see Notes),
< Form bindsubmit = 'formCompare' > < View > < text > Please enter a digit </ text > < INPUT bindInput = 'One' type = 'Number' name = "num1" > </ INPUT > /! --bindinput is used for page when traditional values, name is used for comparison with the numbers, the same below - / </ View > < View > < text > Enter 2 digit </ text > < INPUT bindInput = 'TWO'> </ INPUT > </ View > < Button form-type = "Submit" bindtap = 'CK' > Comparative </ Button > /! --bindtap click event is used to do with the - / </ form >
Thinking text: in a first page (i.e., the first page the user sees, hereinafter the same, is a second page) of the page js arranged to receive two digital codes and a user input size comparative figures
formCompare: function (E) { var STR = 'two numbers are equal' var num1 = Number The (e.detail.value.num1) / - the assignment of a value to the digital input num1 - /! var num2 = number (e.detail.value.num2) / -! input of the second digital value is assigned to num2 - / IF (num1> num2) {/! - digital Comparison - /
str = 'a large number of' } the else IF (num1 < num2 ) {/! - red does not matter here, no problem - / STR = 'a large number of 2' } this.setData ({Result: STR}) /! - comparing the results result in the presence of - / }
Js page is then provided for the first page of code values do pass
Data: {
firstNumber: null, /! - first and secondNumber firstNumber defined as null - /
secondNumber: null,
},
One: function (E) {/! - then the value into the one obtained in firstNumber, secondNumber is likewise - /
this.setData ({
firstNumber: e.detail.value
});
the console.log (this.data.firstNumber);
},
TWO: function (E) {
this.setData ({
secondNumber: e.detail.value
})
the console.log (this.data.secondNumber);
},
Again provided for receiving the code value js page in the second page
onLoad: function (options) { console.log(options.firstNumber), /?--获取传来的firstNumber和scondNumber值--/ console.log(options.secondNumber), console.log(options.result) this.setData({ firstNumber: options.firstNumber, /?----/ secondNumber:options.secondNumber, result:options.result }) }
js page of the first page of the function code also set Click
CK (E) { wx.navigateTo ({ URL: '../test/test?firstNumber='+ the this .data.firstNumber +' & secondNumber = '+ the this .data.secondNumber +' & Result = '+ the this .data.result / -! by clicking on the function, the values are passed in the past - / }) }
After the above code digital value and comparing the result of the first page to the second page display traditional values
The effect is as follows: