weex 实现密码隐藏显示时 input type 改变后 会失去焦点,

<!--登录名-->
      <div class="logoUser">
        <image style="width:30px; height:40px;" src="file://logouserimg.png"></image>
        <input type="text" class="cellInput" :placeholder="placeholderTxt" />
      </div>
      <!--登录名-->

      <!--密码-->
      <div class="logoUser">
        <image style="width:30px; height:40px;" src="file://passimg2.png"></image>
        <input :type="this.isPwd?'text':'password'" ref="passtext" class="cellInput" v-model="pwdStr" placeholder="请输入密码"/>
        <image style="width:45px; height:20px;" :src="isshowpass" @click="showpassclick"></image>
      </div>
      <!--密码-->
       <!--以下是脚步-->
       const passIsShow = true;
showpassclick: function(e)//密码隐藏显示
    {
      
      if (passIsShow) {
       
        this.isshowpass = 'file://noshowimg.png'
        passIsShow = false;
        this.isPwd=false;
      }
      else {
      
        this.isshowpass = 'file://showpassimg.png'
        passIsShow = true;
        this.isPwd=true;
      }
      this.$refs['passtext'].focus();
      

    }

只要 this.isPwd 值改变,密码input 就会失去焦点。请大神指教这个问题怎么破。

阅读 3k
1 个回答
               setTimeout(() => {
                    this.$refs['passtext'].focus()
                }, 200)
撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进