关于前端:UNIAPP图片验证码

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
            },

评论

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

这个站点使用 Akismet 来减少垃圾评论。了解你的评论数据如何被处理