Page({
data:{
verifyCodeUrl:'',
}
getVerifyCode:function(){
Ajax('url?'+new Date().getTime()).then(res=>{
this.setData({
verifyCodeUrl:res.data
})
})
},
changeVerifyCode:function(){
this.getVerifyCode()
},
onLoad: function () {
this.getVerifyCode()
}
});
<view class="input-text">
<view class="text">验证码:</view>
<view class="input">
<input bindinput="bindKeyInput" type="text" name="captch" placeholder="请输入验证码" />
</view>
<view class="code" bindtap="changeVerifyCode">
<image style="180rpx;height:60rpx;display:block" wx:if="{{verifyCodeUrl}}" src="{{verifyCodeUrl}}"></image>
</view>
</view>
<view class="code-alert" bindtap="changeVerifyCode">
<view class="tip">看不清,换一张</view>
</view>