//钩子函数
mounted() {
this.reloadcode();
},
//methods
methods: {
reloadcode() {
let newImg = new Image();
newImg.src = this.checkcodesrc + '?';
//用checkcodeLoding控制验证码的显示,加载的时候不显示
this.checkcodeLoding = true;
newImg.onload = () => {
this.checkcodeLoding = false;
this.checkcodesrc = newImg.src;
}
},
}
请问我这样写有什么问题,这两个函数在路由过来的时候都能执行,但是图片不会更新,图片的地址也不会改变。
小白求告知,感恩。
checkcodesrc这个值会变吗?
正常来说不是直接改img的src为?后加随机数吗。你只加个?,后面又没查询字符串不会请求到新的验证码的吧。