javascript - 如何在 jQuery / JS 的同一页面上的 4 个 div 中加载 4 个不同的页面(包含 d3js 图)?
问题描述
我几乎尝试了所有方法,但我找不到让它正常工作的方法。
我有什么?
table
1 个带有 a和 4的索引页div
(不显示);- 4 带有一些内容(图表)的 html 页面。
我想要什么 ?
每个 div 包含 1 个对应的 html 文件。当我单击表格(“标题”之一)时,div
会显示
结果是什么 ?
基本上,所有的 html 页面都加载在同一个div
. 其他 3 个是空白的……即使没有被调用,也可以在同一个 div 中相互绘制图形。
有什么奇怪的?
当我加载“普通”页面(没有图表 d3js)时,它工作得很好......我想加载图表时一定有问题谢谢你的帮助:)
这是代码:
<body>
<div id="app">
<table width="70%" align="center">
<tr>
<th>Sample id</th>
<th @click='gcmodal = !gcmodal'>GC Dropout</th>
<th @click='atmodal = !atmodal'>AT Dropout</th>
<th @click='dupmodal = !dupmodal'>% Duplicates</th>
<th @click='offmodal = !offmodal'>% Off target</th>
<th @click='trcmodal = !trcmodal'>Total Read Count</th>
</tr>
</table>
<div id='gc' v-show='gcmodal'></div>
<div id='at' v-show='atmodal'></div>
<div id='dup' v-show='dupmodal'></div>
<div id='off' v-show='offmodal'></div>
<div id='trc' v-show='trcmodal'></div>
</div>
</body>
<script>
new Vue({
el: "#app",
data: {
gcmodal:false,
atmodal:false,
dupmodal:false,
offmodal:false,
trcmodal:false,
}
})
$(document).ready(function(){
$('#gc').load('./gc_dropout.html'),
$('#at').load('./at_dropout.html'),
$('#dup').load('./duplicates.html'),
$('#off').load('./off_target.html'),
$('#trc').load('./total_read_count.html')
})
</script>
</body>
解决方案
使用 HTML iframe元素。
它的主要属性是:-
宽度 (嵌入页面的宽度)
height (嵌入页面的高度)
标题 (嵌入页面的标题)
src (您要嵌入的页面的链接)
<body>
<div id="app">
<table width="70%" align="center">
<tr>
<th>Sample id</th>
<th @click='gcmodal = !gcmodal'>GC Dropout</th>
<th @click='atmodal = !atmodal'>AT Dropout</th>
<th @click='dupmodal = !dupmodal'>% Duplicates</th>
<th @click='offmodal = !offmodal'>% Off target</th>
<th @click='trcmodal = !trcmodal'>Total Read Count</th>
</tr>
</table>
<div id='gc' v-show='gcmodal'>
<iframe id="gcTable" width="300" height="300" title="gc dropout" src="./gc_dropout.html" />
</div>
<div id='at' v-show='atmodal'>
<iframe id="atTable" width="300" height="300" title="at dropout" src="./at_dropout.html" />
</div>
<div id='dup' v-show='dupmodal'>
<iframe id="duplicatesTable" width="300" height="300" title="duplicates" src="./duplicates.html" />
</div>
<div id='off' v-show='offmodal'>
<iframe id="offTable" width="300" height="300" title="off target" src="./off_target.html" />
</div>
<div id='trc' v-show='trcmodal'>
<iframe id="trcTable" width="300" height="300" title="total read count" src="./total_read_count.html" />
</div>
</div>
</body>
<script>
new Vue({
el: "#app",
data: {
gcmodal: false,
atmodal: false,
dupmodal: false,
offmodal: false,
trcmodal: false,
}
})
</script>
</body>
推荐阅读
- liquibase - Liquibase 无法使用用户名和密码读取 jdbc postegresql 连接字符串
- xcode - 仅在 TestFlight 中的 SwiftUI CloudKit 同步问题
- typescript - 如何根据同一对象的另一个键有条件地键入一个键
- c# - 一个线程上的 foreach 与 Parrallel.ForEach
- c# - 从任务中获取价值使 C# Xamarin 中的代码崩溃
- pulumi - 如何防止 Pulumi cli 改组堆栈设置文件中的配置
- java - 如何在原始目录中调用多个动画之一
- javascript - 模态 Bootstrap 和 Django 中的录音
- matlab - 在 MATLAB 中使用来自另一个文件的数据添加第二个 y 轴
- matlab - SPM12/CAT12 预处理错误:“这种类型的变量不支持点索引。” 取消关注