无法读取未定义的属性“executeScript”

我按照 chrome 扩展的“入门”教程进行操作,但出现以下错误。

我搜索谷歌,有人说无法访问 content.js 中的“executeScript”,但错误来自 popup.js。

我曾尝试将 'chrome.scripting.executeScript' 更改为 'chrome.tabs.executeScript',它也不起作用。

错误图像

清单文件

{
    "name": "Getting Started Example",
    "version": "1.0",
    "description": "Build an Extension!",
    "permissions": ["storage", "declarativeContent", "activeTab"],
    "background": {
        "scripts": ["background.js"],
        "persistent": false
    },
    "page_action": {
        "default_popup": "popup.html"
    },
    "options_page": "options.html",
    "manifest_version": 2
}

回答

您的权限manifest.json缺少一项,即"scripting".

它应该是这样的:

…
"permissions": ["storage", "declarativeContent", "activeTab", "scripting"],
…

这实际上可以在此处的“入门”页面上看到。


以上是无法读取未定义的属性“executeScript”的全部内容。
THE END
分享
二维码
< <上一篇
下一篇>>