Firefox addon 资源未在firefox加载项中创建

Firefox addon 资源未在firefox加载项中创建,firefox-addon,firefox-addon-sdk,Firefox Addon,Firefox Addon Sdk,我尝试为我的firefox插件创建图像资源。我尝试: var {Cc,Ci,Cu,Cr,Cm} = require("chrome"); var {Services} = Cu.import("resource://gre/modules/Services.jsm"); let res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandl‌​er); res.setSubstitut

我尝试为我的firefox插件创建图像资源。我尝试:

var {Cc,Ci,Cu,Cr,Cm} = require("chrome");
var {Services} = Cu.import("resource://gre/modules/Services.jsm");
let res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandl‌​er); 
res.setSubstitution("test-addon/data", Services.io.newURI('file://C:/Averenges.jpg', null, null));

它起作用了,但只有一次。我不明白为什么。在我启动代码并运行它之后,但什么都没有发生。

您确定要
resource://test-addon/data
没有给你拍那张照片吗?是的,我确定。没有什么!可能是和浏览器有关吗?我试着用nsIFile把图像复制到resource://firefox-addon/data. 我创建
nsILocalFile.initWithPath('C:\\Averenges.jpg')用于函数
copyTo(在nsfile newParentDir中,在AString newName中)我需要从
resouce://firefox-addon/data
。1) 我能用那种方法解决问题吗。2) 如何做
resouce://firefox-addon/data
nslFile类型?我不明白你的问题,请你重写一下。
var {Cc,Ci,Cu,Cr,Cm} = require("chrome");
var {Services} = Cu.import("resource://gre/modules/Services.jsm");
let res = Services.io.getProtocolHandler("resource").QueryInterface(Ci.nsIResProtocolHandl‌​er); 
res.setSubstitution("test-addon/data", Services.io.newURI('file://C:/Averenges.jpg', null, null));