即使在 manifest.json 中正确声明了“image/copy.svg”,我也会收到此错误
拒绝负载
chrome-extension://pofbdjeepddggbelfghnndllidnalpde/images/copy.svg。
资源必须列在 web_accessible_resources 清单键中
为了被扩展之外的页面加载。
如果我转到 chrome-extension://pofbdjeepddggbelfghnndllidnalpde/images/copy.svg 我可以成功看到加载的图像。
css/样式.css
.copy-icon{
content:url('chrome-extension://__MSG_@@extension_id__/images/copy.svg');
height: 16px;
width: auto;
margin-right: 0px;
}
html
<button alt="Copy to clipboard" class="clipboard" data-clipboard-text="TEXT">
<img class="copy-icon"></img>
</button>
清单.json
"manifest_version": 3,
"content_scripts": [
{
"matches": ["https://*.example.com/*"],
"js": ["contents/results.js"],
"css": ["css/style.css"],
"run_at": "document_end"
}
],
"web_accessible_resources": [{
"resources": ["images/copy.svg"],
"matches": [],
"extension_ids": []
}],
The matches
key 应该指定在哪里公开这些资源。
您可以使用<all_urls>
到处暴露他们。
"web_accessible_resources": [{
"resources": ["images/copy.svg"],
"matches": ["<all_urls>"],
}],
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)