V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
FlowerChen
V2EX  ›  微信

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

  •  1
     
  •   FlowerChen · 2017-05-17 15:27:33 +08:00 · 1801 次点击
    这是一个创建于 2530 天前的主题,其中的信息可能已经有所发展或是发生改变。

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

    这里是一个搜索功能 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  
       2017-05-17 15:33:58 +08:00
    可不可以双向绑定呀,或者按照原始方案,根据元素 id 改变元素属性😄
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2735 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 12:44 · PVG 20:44 · LAX 05:44 · JFK 08:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.