我正在尝试开发chrome扩展程序,但我遇到了一个问题。
我需要列出扩展本身内部目录的条目,但是,当我尝试实现chrome.runtime.getPackageDirectoryEntry(function(root) {}
时,控制台通过 chrome.runtime.getPackageDirectoryEntry通知我不是函数< /强>
function getImage(callback) {
chrome.runtime.getPackageDirectoryEntry(function(root) {
root.getDirectory("images", {create: false}, function(localesdir) {
var reader = localesdir.createReader();
// Assumes that there are fewer than 100 locales; otherwise see DirectoryReader docs
reader.readEntries(function(results) {
callback(results.map(function(de){return de.name;}).sort());
});
});
});
}
getImages(function(data){console.log(data);});
我也发布了manifest.json
{
"name": "My ext",
"version":"1.1",
"manifest_version":3,
"content_scripts": [
{
"matches": [
"*://mysite.dev:*/*"
],
"css": ["content.css"],
"js": ["content.js"]
}
],
"web_accessible_resources": ["images/*.png","images/*.gif"]
}
有人可以帮助我吗?