在使用JavaScript时可以调试DukeScript吗?我试过添加FirebugLite
<script type='text/javascript' src='http://getfirebug.com/releases/lite/1.2/firebug-lite-compressed.js'></script>它加载,这是很棒的,但它没有可见的$root模型。而且,我也不知道是否可以添加断点。
发布于 2015-06-02 23:57:59
在一定程度上,可以包括FirebugLite。例如,参见here。我发现的一个问题是Firebug加载,但是没有模型的可见性,$root返回未定义的。我试图通过在主/资源下创建Javascript资源MyResource.js来解决这个问题
MyResource = {
loadFirebug: function(){
if (!document.getElementById('FirebugLite')){
E = document['createElement' + 'NS'] && document.documentElement.namespaceURI;
E = E ? document['createElement' + 'NS'](E, 'script') : document['createElement']('script');
E['setAttribute']('id', 'FirebugLite');
E['setAttribute']('src', 'https://getfirebug.com/' + 'firebug-lite.js' + '#startOpened');
E['setAttribute']('FirebugLite', '4');(document['getElementsByTagName']('head')[0] || document['getElementsByTagName']('body')[0]).appendChild(E);
E = new Image;E['setAttribute']('src', 'https://getfirebug.com/' + '#startOpened');
}
},
someProperty: "someProperty"
};然后,我们创建了一个对应的Java类来加载资源
@JavaScriptResource("MyResource.js")
public class MyResource {
@net.java.html.js.JavaScriptBody(
args = {}, body =
"MyResource.loadFirebug();"
)
public static native void loadFireBug();
} 现在,在onPageLoad() Java方法中,我们可以调用加载FirebugLite的JavaScript方法
/**
* Called when the page is ready.
*/
public static void onPageLoad() throws Exception {
d = new Data();
d.setMessage("Hello World from HTML and Java!");
d.applyBindings();
MyResource.loadFireBug();
}现在,当Firebug启动时,它至少有一个包围资源的范围。我们仍然不能添加断点,因为资源没有出现在文件下面。也许DukeScript专家可以建议一种更好的方法来处理这个问题。
注1:您可以使用load引导,只需将其包含到带有脚本标记的页面中即可。请参阅here
注2:不幸的是,FireBug Lite似乎在版本1.2之后出现了一些引导问题。请参阅here
注3:关于如何从javascript上下文访问DukeScript模型的DukeScript
https://stackoverflow.com/questions/30608556
复制相似问题