FlowerChen
V2EX  ›  微信

菜鸟跪求大神指点!微信小程序开发

  •  1
     
  •   FlowerChen · May 17, 2017 · 2616 views
    This topic created in 3291 days ago, the information mentioned may be changed or developed.

    最近着手新项目是一个微信小程序 遇到问题是这样的:

    这里是一个搜索功能 input 旁边有一个小叉的 icon,点击那个灰白小叉,input 置空

    DOM 结构是这样的

        <form action="." bindsubmit="formsubmit" >
          <i class="fa fa-search"></i>
          <input type="search" bindinput="bindKeyInput" placeholder="请输入公司名称“/>
          <i class="fa fa-times-circle" wx:if="{{inputValue.length > 0}}" bindtap="clearValue"></i>
        </form>
    

    js 是这样的

        bindKeyInput: function(e){
            this.setData({
              inputValue: e.detail.value
            })
          },
        clearValue:function(e){
            this.setData({
              //这里应该怎么改变 input 的内容呢?数据不是双向绑定 不能直接将 inputValue 置空
            })
          },
    
    WuMingyu
        1
    WuMingyu  
       May 17, 2017
    可不可以双向绑定呀,或者按照原始方案,根据元素 id 改变元素属性😄
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   973 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 29ms · UTC 22:17 · PVG 06:17 · LAX 15:17 · JFK 18:17
    ♥ Do have faith in what you're doing.