我正在使用 ReactJS 创建一个 chrome 扩展。我基本上想要两个页面 - 一个用于弹出窗口,第二个页面通过单击弹出窗口上的按钮在新选项卡中打开。
最佳答案
首先,我建议遵循本教程的基础知识。
https://medium.com/@gilfink/building-a-chrome-extension-using-react-c5bfe45aaf36
这将对基础知识有很大帮助。一般的总结是你想改变中的manifest.json。公共(public)文件夹 chrome 扩展 manifest.json 的样子。在该 manifest.json 中,您希望添加 index.html(也在公用文件夹中)以在您真正希望调用它的任何位置进行调用。
下面的例子:
{
"manifest_version": 2,
"short_name": "XXX",
"name": "XXX",
"version": "1.0.2",
"browser_action": {
"default_popup": "index.html", //popup page occurs when you click on the favicon
"default_title": "Open the popup"
},
"chrome_url_overrides": {
"newtab": "index.html" //registers an override page (index.html) to the newtab page.
}
}
覆盖其他页面:
https://developer.chrome.com/extensions/override
注意 :确保在使用 npm run build 构建它并在“Load Unpackaged”中选择 chrome 扩展时,您选择的是构建文件夹而不是公用文件夹。
关于javascript - 如何创建可以从弹出窗口打开新选项卡的 ReactJS chrome 扩展?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51955926/