直接上代码喔喔喔喔喔喔喔喔~~
<input name="username" password="{{passwordHideShow}}" placeholder-style="color:#bdbdbd" type="text"maxlength="20" value="{{passwordNumber}}" bindinput="passwordInput" /><view class="icon " catchtap="passwordClick" data-type="pas"><image src="{{passwordHideShow?'../../images/look.png':'../../images/noLook.png'}}"></image> </view>
data: {passwordHideShow: true, //小眼睛passwordNumber: '', //密码// 重复passwordHideShow1: true, //小眼睛passwordNumber1: '', //密码},showPwdChange: function() {this.setData({passwordHideShow: !this.data.passwordHideShow})},passwordClick(e) {console.log(this.data.passwordNumber)if(e.currentTarget.dataset.type=='pas'){// 密码this.setData({passwordHideShow: this.data.passwordHideShow ? false : true})return }// 重复密码this.setData({passwordHideShow1: this.data.passwordHideShow1 ? false : true})},passwordInput(e) {this.setData({passwordNumber: e.detail.value})},passwordInput1(e) {this.setData({passwordNumber1: e.detail.value})},
完事啦啦啦啦啦啦啦啦~~~~~~~~~~~