请问如何清空input组件中已经输入的内容?

发布于 7 年前作者 lhe14226 次浏览最后编辑 6 年前来自 ask

如题

4 回复
lei75
lei751 楼6 年前

为空没用  要设为空数组

nalai
nalai2 楼6 年前
<view class="main">
  <view class="section">
    <textarea id="idrecord" class="record" maxlength="0" bindchange="bindChange" value="{{record}}" placeholder="聊天记录" auto-height />
  </view>
  <view class="section">
    <form>
      <input id="idsendmsg" class="sendtxt" bindchange="bindChange" value="{{sendmsg}}" placeholder="消息" type="text" auto-focus />
      <view class="btn-area">
        <button form-type="reset" type="primary" bindtap="btnSendMsg">发送消息</button>
      </view>
    </form>
  </view>

需要清空的加在form里,button设置为form-type=“reset”

chao63
chao633 楼6 年前

绑定输入事件 返回空

juan10
juan104 楼5 年前

<input placeholder=“姓名” auto-focus  value=“{{name}}”/>

data: {

    name: ‘’

  },

  onClearTap: function (e) {

    this.setData({

      name: ‘’

    })

  },