在GWT中使用ScriptInjector和参数/数据属性

时间:2014-11-07 00:07:25

标签: javascript gwt

如何将id = someScript和param1 = value1传递给GWT ScriptInjector?即,JS:

<script src="https://blah.com/someScript.js" id="someScript" param1="value1"></script>

可以像这样加载:

ScriptInjector.fromUrl("https://blah.com/someScript.js").setCallback(new Callback<Void, Exception>() {
    public void onSuccess(Void result) {
    }
    public void onFailure(Exception reason) {
    }
}).inject();

但是,我在哪里可以传入id =“someScript”和param1 =“value1”?

1 个答案:

答案 0 :(得分:0)

通过URL传递参数,就像通常在URL中传递参数一样。

ScriptInjector.fromUrl("https://blah.com/someScript.js?param1="+value1).setCallback(new Callback<Void, Exception>() {
    public void onSuccess(Void result) {
    }
    public void onFailure(Exception reason) {
    }
}).inject();