小程序模板网

微信小程序问题汇总及详解《五》点击发送清空input值

作者:JoyJin,来自授权地址 
wxml:

 

				
  1. <view class="btns" wx:for="{{phoneList}}" wx:key="id">
  2. <input bindinput="writeNumber" type="number" value="{{item.phone}}" class="btn1" maxlength="11" placeholder="请输入电话号码" data-index="{{index}}"/>
  3. <image src="../Image/detele1.png" class="icon1" bindtap="icon" data-index="{{index}}"></image>
  4. </view>

js:

 

				
  1. //点击清空电话号码
  2. icon:function(e){
  3. var that = this;
  4. var index = e.currentTarget.dataset.index;
  5. var list = that.data.phoneList;
  6. list[index].phone = '';
  7. that.setData({
  8. phoneList: that.data.phoneList
  9. })
  10. },

点击发送清空input值:

 

				
  1. <form bindreset="cleanInput">
  2. <input type="text" placeholder="输入新消息" bindinput="bindMessage"></input>
  3. <button bindtap="sendMessage" formType="reset">发送 </button>
  4. </form>
 

				
  1. Page({
  2. data: {
  3. sendInfo: '',
  4. userMessage: ''
  5. },
  6. bindMessage: function(e) {
  7. this.setData({
  8. userMessage: e.detail.value
  9. })
  10. },
  11. cleanInput: function() {
  12. var setMessage = { sendInfo: this.data.userMessage }
  13. this.setData(setMessage)
  14. }
  15. })


易优小程序(企业版)+灵活api+前后代码开源 码云仓库:starfork
本文地址:https://www.eyoucms.com/wxmini/doc/course/23521.html 复制链接 如需定制请联系易优客服咨询:800182392 点击咨询
QQ在线咨询