【发布时间】:2019-12-07 15:09:26
【问题描述】:
我正在使用dojo 工具包的TabConatiner 创建一个Web 应用程序。
单击菜单上的fn_addTab("/page", this) 会将页面显示为选项卡。它看起来像iframe。
但是有一个问题。导入“href”属性的选项卡,jsp 中的脚本不起作用。如果映射到控制器的 url 显示在选项卡中,jsp 内的脚本是否也必须工作?
home.js
function fn_addTab(url, node) {
require([
'dijit/registry',
'dijit/layout/ContentPane',
'dojo/domReady!'
], function(registry, ContentPane) {
const tabContainer = registry.byId("tabContainer");
...
let tab = registry.byId(tabId);
if(typeof tab === 'undefined') {
tab = new ContentPane({
id: tabId,
title: sidebarMenuText,
href: url,
closable: true
});
tabContainer.addChild(tab);
}
tabContainer.selectChild(tab);
fn_initActiveMenu(node);
});
}
page.jsp
<section class="wrapper">
<!-- page start -->
<div class="row">
<div class="col-sm-12">
<div class="panel panel-default">
<div class="panel-heading">
<h2 class="page-header">page 3</h2>
</div>
<div class="panel-body">
<button id="btn" type="button" onclick="helloWorld()">Click</button>
</div>
</div>
</div>
</div>
<!-- page end-->
</section>
<script>
function helloWorld() {
alert('helloWorld?');
}
</script>
那个按钮不起作用。 helloWorld() 未定义。
控制器
@RequestMapping(value = "/page")
public String page() {
return "page/page";
}
【问题讨论】:
标签: javascript spring dojo