【问题标题】:Using NOTY JS notification library in Chrome extension在 Chrome 扩展中使用 NOTY JS 通知库
【发布时间】:2020-04-03 04:10:32
【问题描述】:

我正在尝试在 Chrome 扩展程序中使用通知库 Noty。

它说您可以通过以下方式安装:

<link href="lib/noty.css" rel="stylesheet">
<script src="lib/noty.js" type="text/javascript"></script>

我尝试将其添加到我的内容脚本 .html,但是,在 .js 页面中调用新通知失败。

{
  "name": "--",
  "version": "1.0",
  "description": "--",
  "background": {
    "scripts": ["background.js"],
    "persistent": false
  },
  "content_scripts": [
    {
      "matches": ["-removed-"],
      "js": ["popup.js"]           **where I am trying to fire off a notification**
    }
  ],
  "manifest_version": 2,
  "browser_action": {
    "default_popup": "popup.html"  **where I added the script and link**
  },
  "permissions": [
    "storage",
    "notifications"
  ]
}

我已经阅读了一些不同的主题,但不了解整个过程。这是一个完全的禁忌,还是相当合理的做法?我只需要能够在 popup.js 文件中调用通知即可。

【问题讨论】:

    标签: javascript google-chrome google-chrome-extension noty


    【解决方案1】:

    由于您的问题不正确,因此我假设您在安装 Noty.js 时遇到困难来回答这个问题。因此,为此,您首先需要使用 npm(npm install noty) 或 yarn 或 bower 下载 noty.js 文件,然后必须将 .js 和 .css 文件复制到目录中,然后需要通过脚本和样式包含标签。之后你就可以调用 Noty(); 如果我的回答不正确并且我错了,请清除我并随时询问您是否有任何问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-11-11
      • 2014-09-17
      • 2016-05-15
      • 1970-01-01
      • 1970-01-01
      • 2011-06-26
      • 2012-07-18
      • 2022-07-16
      相关资源
      最近更新 更多