首页 > 解决方案 > 将本地存储项设置为键有反斜杠的浏览器

问题描述

我想将本地存储项设置为键有反斜杠的浏览器。例如,密钥看起来像

CognitoIdentityServiceProvider.\admin.idToken

我将以下查询与“双反斜杠 \\”一起使用,但它仍然在浏览器的 LocalStorage 中产生垃圾值。如果我们使用 console.log(CognitoIdentityServiceProvider.\\admin.idToken),它会在控制台中打印预期的输出,但在浏览器中,\ 无法识别。

browser.executeScript('localStorage.setItem("CognitoIdentityServiceProvider.\\admin","token")');

标签: javascripttypescriptbrowser

解决方案


推荐阅读