uniapp显示图片验证码
后盾返回的是流文件的格局,查了很多,都是应用arrayBuffer接管,然而没有成果,所以间接应用下方代码。
<image :src="imgSrc" class="w_img" mode="" @click="getCode()"></image>
动静扭转imgSrc触发验证码更新
mounted() { this.getCode() },
getRangeCode() { var orgStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789' let returnStr = '' for (var i = 0; i < 6; i++) { returnStr += orgStr.charAt(Math.floor((Math.random() * orgStr.length))) } return returnStr },
减少工夫戳+随机6位字符.
getCode() { this.codeKey = new Date().getTime() + this.getRangeCode() this.imgSrc = API_ROOT + '/v1/app/user/getCode?codeKey=' + this.codeKey },