我希望我的页面能够动态加载 javascriptbody:
<script type= "text/javascript" src="this path should be decided from wicket dynamically"/>
我正在使用检票口1.4版所以JavaScriptResourceReference 在我的版本中不存在(据我检查,事实并非如此')
我该如何解决这个问题?
提前致谢 :)。
我将我的评论指定为答案。
您可以使用以下代码片段:
WebMarkupContainer scriptContainer = new WebMarkupContainer("scriptContainer ");
scriptContainer .add(new AttributeAppender("type", Model.of("text/javascript")));
scriptContainer .add(
new AttributeAppender("src", urlFor(
new JavaScriptResourceReference(
YourClass.class, "JavaScriptFile.js"), null).toString()));
add(scriptContainer );
以及相应的html:
<script wicket:id="scriptContainer "></script>
只需更改字符串即可JavaScriptFile.js
加载任何其他 Javascript 文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)