我尝试使用 Manifest v3 创建一个 chrome 扩展。创建通知时,我需要设置一个 iconUrl。图标是“48.png”,它与根文件夹中的 manifest.json 一起使用。
我收到一个错误而不是我的通知:
Error in event handler: ReferenceError: Image is not defined
Run Code Online (Sandbox Code Playgroud)
在 v3 中,他们更改了 web_accessable_resources 定义。我认为我设置错了但它也可能是其他东西..
我的清单.json
{
"name": "Hello Extensions",
"description":
"Shows off desktop notifications, which are \"toast\" windows that pop up on the desktop.",
"version": "1.0",
"icons": {"16": "16.png", "48": "48.png", "128": "128.png"},
"permissions": ["alarms","storage", "notifications"],
"background": {"service_worker": "background.js"},
"manifest_version": 3,
"web_accessible_resources": [{
"resources": ["48.png"],
"matches": [],
"extension_ids": [],
"use_dynamic_url": false
}]
}
Run Code Online (Sandbox Code Playgroud)
我的背景.js
chrome.runtime.onInstalled.addListener(function() {
var options = { …Run Code Online (Sandbox Code Playgroud)