Chrome扩展程序网络存储返回null

大家好,我有2个脚本 popup.js content.js

Popup.js包含用于扩展名HTML弹出窗口的javascript,它具有一个简单的按钮和用于验证许可证密钥的文本输入-如果密钥有效,我将使用以下代码将密钥保存到Webstorage:

copyLink (url) {
    const el = document.createElement('textarea');
    el.value = url;
    document.body.appendChild(el);
    el.select();
    document.execCommand('copy');
    document.body.removeChild(el);
},

然后,当用户下次单击扩展名并显示弹出窗口时,我将检查键“许可证是否存在”-这一切正常。但是,当我在扩展程序的后台运行的content.js脚本上尝试相同的代码时:

localStorage.setItem("License",key);

即使poppop.js可以成功完全获取其值,但webstorage密钥确实存在也总是返回null。

我该如何解决?

iCMS 回答:Chrome扩展程序网络存储返回null

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/2011231.html

大家都在问