How to randomly post questions in the answer applet: 1. To implement the question, the code is [
;]; 2. Random number implementation, the code is [goto_logs: function(){}].
##Related learning recommendations: WeChat Mini Program Development
How to randomly post questions in the answer applet:
The initial interface is as shown in 1. If you enter the wrong answer, click OK and make sure the text below shows "Wrong!" , click to jump, and an integer between 0 and 9 is randomly generated below the jump, as shown in 2. The answer is entered correctly, click OK, and the text display is "Right!". Start with simplicity and forget about anything else. index.wxml code:<form bindsubmit="formBindsubmit"> <view style="display:flex;"> <label>请问你的名字?</label> </view> <view style="display:flex;"> <label>答案:</label> <input name="psw" placeholder="请输入答案!"/> </view> <view style="display:flex;margin-top:30px;"> <button style="width:30%;" formType="submit" >确定</button> </view> </form> <view>{{tip}}</view> <view style="display:flex;margin-top:30px;"> <button style="width:30%;" bindtap="goto_logs" >跳转</button> </view> <view>{{suiji}}</view>
Page({ data: { // text:"这是一个页面" tip: '对错', suiji:'00' }, formBindsubmit: function (e) { if (e.detail.value.psw == "无面人") { this.setData({ tip: '对了!' }) } else { this.setData({ tip: '错了!' }) } }, goto_logs: function () { var random = Math.floor(Math.random() * 10); this.setData({ suiji: random }) }, })
The above is the detailed content of How does the quiz mini program randomly post questions?. For more information, please follow other related articles on the PHP Chinese website!