0
点赞
收藏
分享

微信扫一扫

Vue项目中处理key=value格式的数据-demo

Vue项目中处理key=value格式的数据-demo_字符串

要从qrCode字符串中获取expiredAt的值,你可以使用JavaScript的字符串操作方法。

以下是一个示例,展示如何提取expiredAt的值:

const qrCode = 'expiredAt=1693821037721&token=c214de74cf5847239da3005c9465025e';
const params = new URLSearchParams(qrCode);
const expiredAt = params.get('expiredAt');

console.log(expiredAt); // 输出:1693821037721

在上面的示例中,我们使用URLSearchParams构造函数将qrCode字符串解析为URL搜索参数。然后,我们使用URLSearchParams对象的get方法来获取expiredAt参数的值。

注意:URLSearchParams构造函数在现代浏览器中可用。如果你的目标是旧版浏览器,你可能需要使用其他方法来解析URL搜索参数

举报

相关推荐

0 条评论