localStorage未在background.js中定义
我试图使用background.js 在我的扩展中获取和设置,但每当我运行扩展时,我都会收到错误消息,指出referenceError: localStorage 未定义。
而如果我在 App.js 中使用它,它会在本地存储中获取和设置。
注意:我使用的是清单 v3
chrome.cookies.get(
{ url: "https://www.xxxx.com/", name: "abc" },
async (cookie) => {
const cookieValue: any = cookie?.value;
oldJwtToken = localStorage.getItem("abc");
console.log(cookieValue);
console.log(oldJwtToken);
}
I am trying to get and set in my extension using background.js but whenever I run the extension I get the error saying that referenceError: localStorage is not defined.
whereas if I use it in my App.js , it is getting and setting in the local storage.
Note: I am using manifest v3
chrome.cookies.get(
{ url: "https://www.xxxx.com/", name: "abc" },
async (cookie) => {
const cookieValue: any = cookie?.value;
oldJwtToken = localStorage.getItem("abc");
console.log(cookieValue);
console.log(oldJwtToken);
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论