欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

微信小程序簡(jiǎn)單實(shí)現(xiàn)form表單獲取輸入數(shù)據(jù)功能示例

 更新時(shí)間:2017年11月30日 10:10:25   作者:FutrueJet  
這篇文章主要介紹了微信小程序簡(jiǎn)單實(shí)現(xiàn)form表單獲取輸入數(shù)據(jù)功能,涉及微信小程序針對(duì)form表單的事件綁定及數(shù)據(jù)獲取等相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了微信小程序簡(jiǎn)單實(shí)現(xiàn)form表單獲取輸入數(shù)據(jù)功能。分享給大家供大家參考,具體如下:

1、效果展示

2、關(guān)鍵代碼

index.wxml

<form bindsubmit="formBindsubmit" bindreset="formReset">
 <view style="display:flex;">
  <label>用戶(hù)名:</label>
  <input name="userName" placeholder="請(qǐng)輸入用戶(hù)名!" />
 </view>
 <view style="display:flex;">
  <label>密碼:</label>
  <input name="psw" placeholder="請(qǐng)輸入密碼!" password="true" />
 </view>
 <view style="display:flex;margin-top:30px;">
  <button style="width:30%;" formType="submit" >登錄</button>
  <button style="width:30%" formType="reset" >重置</button>
 </view>
</form>
<view>{{tip}}</view>
<view>{{userName}}</view>
<view>{{psw}}</view>

index.js

Page({
 data:{
  // text:"這是一個(gè)頁(yè)面"
  tip:'',
  userName:'',
  psw:''
 },
 formBindsubmit:function(e){
  if(e.detail.value.userName.length==0||e.detail.value.psw.length==0){
   this.setData({
    tip:'提示:用戶(hù)名和密碼不能為空!',
    userName:'',
    psw:''
   })
  }else{
   this.setData({
    tip:'',
    userName:'用戶(hù)名:'+e.detail.value.userName,
    psw:'密碼:'+e.detail.value.psw
   })
  }
 },
 formReset:function(){
  this.setData({
   tip:'',
   userName:'',
   psw:''
  })
 }
})

3、完整實(shí)例代碼點(diǎn)擊此處本站下載。

希望本文所述對(duì)大家微信小程序開(kāi)發(fā)有所幫助。

相關(guān)文章

最新評(píng)論