<input type="{{show}}" value='{{password}}' bindinput='getPassWord' placeholder="请输入密码" placeholder-class="input-placeholder"></input>
<image class="psdMage" bindtap="showPassword" src="/pages/img/showPassword.png"></image>
data: {
isShow: false,
show:"text"
},
showPassword: function() {
if (this.data.isShow) {
this.setData({
isShow:false,
show:"password"
})
} else {
this.setData({
isShow: true,
show: "text"
})
}
},
<input type="text" value='{{password}}' bindinput='getPassWord' placeholder="请输入密码" placeholder-class="input-placeholder"wx:if="{{show}}" />
<input type="password" value='{{password}}' bindinput='getPassWord' placeholder="请输入密码" placeholder-class="input-placeholder"wx:if="{{!show}}" />
// 老毛病了,可以通过以上方式规避。如果是点击眼睛切换后需要聚焦input,再加上 focus 属性