刷新验证码为什么要加入new Date()?
// 刷新验证码
refreshCode() {
this.codeSrc =
'http://localhost:8080/CCPP/admin/captcha/captchaImage?' + new Date()
},
浏览器中存在缓存
缓存是先看请求地址是不是一样,地址一样就取出缓存内容
加new Date().getTime(),每次请求地址就不一样,保证了不从缓存里面取。
new Date().getTime() 表示当前时间毫秒值
参考:https://blog.youkuaiyun.com/weixin_43247621/article/details/105399052
通过Date.prototype可以查看Date对象的所有方法
new Date()可以通过调用getTime()方法获取到当前时间的时间戳。
+new Date()
+号的作用:加号能够将后面new Date()对象的值转为Number类型,从而得到与上面getTime()、valueOf()一致的时间戳(数值)
参考https://blog.youkuaiyun.com/weixin_42919342/article/details/132892658