Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/454.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在我的chrome扩展中访问chrome通知API?_Javascript_Google Chrome Extension_Notifications - Fatal编程技术网

Javascript 如何在我的chrome扩展中访问chrome通知API?

Javascript 如何在我的chrome扩展中访问chrome通知API?,javascript,google-chrome-extension,notifications,Javascript,Google Chrome Extension,Notifications,根据:我需要这样做: const notification = () => { var options = { type : "basic", title : "Some title", message: "Some message", iconUrl: "icons/icon19.png" // YES this png does exist } chrome.notifications.create( 'id_1'

根据:我需要这样做:

const notification = () => {
  var options = {
      type : "basic",
      title : "Some title",
      message: "Some message",
      iconUrl: "icons/icon19.png" // YES this png does exist
  }
  chrome.notifications.create(
      'id_1',
      options,
      function() {
        console.log(chrome.runtime.lastError);
      }
    );
}
但是,当我运行扩展时,我得到一个错误:
uncaughttypeerror:无法读取未定义的属性“create”

我在
manifest.json

"permissions": [
    "https://target-site.org/*",
    "notifications"
  ],
我也尝试过做
console.log(chrome)

它返回不包含通知的对象。这就是它的输出:


如何访问chrome扩展项目中的通知?

内容脚本无法使用大多数扩展API。使用背景或浏览器操作脚本。谢谢!将尝试