gpt4 book ai didi

XUL + javascript 模块 : TypeError: xxx. yyyy 不是函数

转载 作者:行者123 更新时间:2023-11-28 07:11:16 28 4
gpt4 key购买 nike

我正在使用 XUL 和模块 ( https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Using )

我定义了一个小模块:在hello01/chrome/content/js/hello.jsm下

this.EXPORTED_SYMBOLS = ["Hello", "foo"];

function foo() {
return "foo";
}

var Hello = {
name : "bar",
size : 3,
incr : function()
{
this.size++;
return this.size;
},
open : function()
{
return this.incr();
}
};

此模块是从 hello01/chrome/content/main.js 加载的

Components.utils.import("chrome://hello/content/js/hello.jsm");

function jsdump(str) {
Components.classes['@mozilla.org/consoleservice;1']
.getService(Components.interfaces.nsIConsoleService)
.logStringMessage(str);
}

function showMore() {
document.getElementById("more-text").hidden = false;
jsdump("Hello!");
jsdump(Hello.incr());
jsdump(Hello.open());
}

来自 xul 窗口:

(...)
<button label="More >>" oncommand="showMore();"/>
(...)

当我点击按钮时,我在 jsconsole 中看到:

Hello !
4
Error: TypeError: Hello.open is not a function
Source File: chrome://hello/content/main.js
Line: 14

为什么 xul 知道 Hello.incr 但不知道 Hello.open

更新:代码可在此处获取:https://github.com/lindenb/xul-bootstrap

最佳答案

好的,明白了:XUL-Runner 在 ${HOME}/${VENDOR} 下缓存一些文件它默默地忽略我的更改并使用缓存中的旧文件。请参阅XULRunner ignores updates on edited files

关于XUL + javascript 模块 : TypeError: xxx. yyyy 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31288100/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com