我正在尝试获取当前标签页的网址。但是,我不断收到以下错误消息
Error handling response: TypeError: Cannot read property 'url' of undefined
at chrome-extension://haencpbflmfmghcblmadiohldhpidihf/background.js:3:25
manifest.json
{
"name": "x",
"version": "1.0",
"description": "y!",
"permissions": [
"tabs"
],
"background": {
"scripts": ["background.js"]
},
"manifest_version": 2}
background.js
console.log("h")
chrome.tabs.query({currentWindow: true, active: true}, function(tabs){
console.log(tabs[0].url);
});
我尝试用activeTab替换选项卡权限,但是我仍然遇到相同的错误。