我正在尝试使用React构建chrome扩展,我设法将manifest.json设置为:
{
"short_name": "GitMap",
"name": "GitMap",
"manifest_version": 2,
"browser_action": {
"default_popup": "index.html",
"default_title": "GitMap"
},
"permissions": [
"tabs"
],
"version": "1.0"
}
。我想在我的React应用程序的app.js文件中使用chrome.tabs.query({ "currentWindow":true}, function(tab) { blahblahblah}
访问当前活动选项卡的url,但我收到此错误:TypeError: Cannot read property 'query' of undefined
。
如何从反应文件中访问“chrome”方法?谢谢
尝试此解决方案