
很多二维码都需要设置过期时间,比如扫码登录、付款二维码等。下面web建站小编给大家详细介绍一下实现代码!
具体代码如下:
export default {
name: "qrCode",
data() {
return {
codeStatus: 1, // 1- 未扫码 2-扫码通过 3-过期
effectiveTime: 30, // 有效时间
qrCodeTimer: null // 有效时长计时器
uid: '',
time: ''
};
},
methods: {
// 轮询获取二维码状态
getQcodeStatus() {
if(!this.qsCodeTimer) {
this.qrCodeTimer = setInterval(()=> {
// 二维码过期
if(this.effectiveTime <=0) {
this.codeStatus = 3
clearInterval(this.qsCodeTimer)
this.qsCodeTimer = null
return
}
this.effectiveTime--
}, 1000)
}
},
// 刷新二维码
refreshCode() {
this.codeStatus = 1
this.effectiveTime = 30
this.qsCodeTimer = null
this.generateORCode()
}
},
标签: 生成二维码
上面是“如何设置二维码的时效性?(设置过期时间)”的全面内容,想了解更多关于 vuejs 内容,请继续关注web建站教程。
当前网址:https://m.ipkd.cn/webs_3379.html
声明:本站提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请发送到邮箱:admin@ipkd.cn,我们会在看到邮件的第一时间内为您处理!

Design Arena:一个全球性的AI设计评测平台
一款免费商用的手写风格,为设计增添温度与独特性的字体——辰宇落雁体
Ourmacs:一个专为Mac用户设计的Mac软件搜索引擎
处理器I7-14650HX参数大全
Claude 3.7 Sonnet:一款出自Anthropic的AI推理与编程能力的全新突破
Magicboat AI官网使用入口,90%成本削减+数小时出片,一人搞定专业级视频制作