原生小程序 之 input切换 text与password类型
login.wxml
<input type="text" password="{{ !isShowPwd }}" placeholder="请输入密码" value='{{password}}' maxlength="11" class="phonePassword" placeholder-class="placeholderClass"></input>
<image class='input-img input-img2' bindtap='changePwdType' src="{{isShowPwd ? '/static/login/viewPassword.png' : '/static/login/hidePassword.png'}}"></image>
login.js
data: {
isShowPwd:true,
phoneNum: '',
password: '',
},
changePwdType(){
if (this.data.isShowPwd) {
this.setData({
isShowPwd:false,
})
} else {
this.setData({
isShowPwd: true,
})
}
},