CHROME扩展:如何在popup.js中导入多个文件?

时间:2019-04-27 15:32:54

标签: javascript google-chrome-extension

我有一个带有popup.js文件的chrome扩展程序。我的主要问题是popup.js文件中有6个函数,我想将这些函数分成多个JS文件,然后将其导入popup.js中(主要用于维护问题)

在我的情况下,Require无效,有人知道该怎么做吗?

manifest.json

{
    "name": "xxx",
    "version": "1.2.7",
    "description": "xxx",
    "manifest_version": 2,
    "icons": { "128": "0.png" },

    "background": {
        "scripts": ["background.js"],
        "persistent": false
    },
    "permissions": [
        "activeTab",
        "storage",
        "contextMenus",
        "background",
        "cookies",
        "notifications",
        "https://www.linkedin.com/*",
        "https://linkedin.com/*"
    ],
    "browser_action": {
        "default_popup": "popup.html"
    }
}

popup.html

<!DOCTYPE html>
<html lang="en">
    <head>
    <meta charset="UTF-8" />
        <link rel="stylesheet" href="style.css" />
    </head>
    <body>

      <h1 class="ui center aligned header ">
         <span class="highlighted-orange">HubLinked
         </span>
      </h1>


    </body>
    <script type="text/javascript" src="popup.js"></script>
</html>

0 个答案:

没有答案