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="width:180rpx;height:60rpx;display:block" wx:if="{{verifyCodeUrl}}" src="{{verifyCodeUrl}}"></image>
</view>
</view>
<view class="code-alert" bindtap="changeVerifyCode">
<view class="tip">看不清,换一张</view>
</view>
![](https://img2024.cnblogs.com/blog/35695/202408/35695-20240825082459112-376424429.jpg)