对于网络应用清单,Chrome.tabs将返回未定义状态

时间:2017-10-17 09:47:36

标签: javascript google-chrome google-chrome-extension google-chrome-devtools manifest.json

我的清单文件是manifest.json

{
  "name": "Test",
  "description": "Test Desc",
  "version": "1.1",
  "background": {
        "scripts": ["./others/dependencies/src/background_tabs.js"]
  },
  "permissions": [
    "tabs", "http://*/*", "https://*/*", "https://ajax.googleapis.com/"
  ],
  "browser_action": {
      "default_title": "Test Title"

  },
  "manifest_version": 2
}

我的Background_Tabs.js是

getCurrentTab(){ 

    console.log(chrome.tabs);
};

 getCurrentTab();

Atlast我将清单文件添加到index.html网络应用程序 -

<!DOCTYPE HTML>
<html>
<head>
    <link rel="shortcut icon" href="./resources/images/favicon.ico" type="image/x-icon" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=10, user-scalable=yes">

    <title>Test</title>

    <link rel="manifest" href="./manifest.json">
...

现在,当我在加载网页后看到我的控制台时 - 它返回为未定义的&#39; chrome.tabs&#39;。

我该如何解决这个问题?

0 个答案:

没有答案