微信小程序入门一个

1、index.wxml内容如下:

<!--index.wxml-->
<view class="container">


<form bindsubmit="formSubmit" bindreset="formReset">
<view class="section">
<text>远上寒山石径斜,__________________。</text>
</view>
<view class="section">
<input name="daan" placeholder="答案" />
</view>
<view class="btn-area">
<button formType="submit">提交</button>
<button formType="reset">清空</button>
</view>
</form>
<view class="section">
{{zhuangtai}}
</view>
</view>
 
2、index.json的内容如下:
{
"usingComponents": {},
  "zhuangtai":{}
}
 
3、index.js的内容如下:
//index.js
let app = getApp()

Page({
  data: {
    isSubmit: false,
    daan: "",
  },
  formSubmit: function (e) {
    var daan=e.detail.value.daan;
   if(daan!="白云深处有人家"){
   console.log('正确');
   this.setData({
     zhuangtai:'错误请从新输入'
   })
  }
  else{
     this.setData({
       zhuangtai:'正确,加十分'
     })
  }
  },
  formReset: function () {
  
  }
 
})

猜你喜欢

转载自www.cnblogs.com/yp703/p/10720130.html
0条评论
添加一条新回复