<div class="layui-card-body" style="padding:0;"> <div class="layui-tab layui-tab-card" style="margin:0" lay-filter="myTaskTabs"> <ul class="layui-tab-title"> <li class="layui-this">待處理</li> <li>我建立</li> <li>已完成</li> <li>所有</li> </ul> <div class="layui-tab-content" style="padding:0px;"> <div class="layui-tab-item layui-show"> <iframe src="myTaskTodoList.jsp" style="width:100%;height:94%;" frameborder="0" name="iframe0" ></iframe> </div> <div class="layui-tab-item"> <iframe src="myCreateTaskList.jsp" style="width:100%;height:94%;" frameborder="0" name="iframe1" ></iframe> </div> <div class="layui-tab-item"> <iframe src="myTaskDoneList.jsp" style="width:100%;height:94%;" frameborder="0" name="iframe2" ></iframe> </div> <div class="layui-tab-item"> <iframe src="myTaskList.jsp" style="width:100%;height:94%;" frameborder="0" name="iframe3" ></iframe> </div> </div> </div> </div>
<script> layui.config({ base: '${ctxLayui}/layuiadmin/' }).extend({ index: 'lib/index' }).use(['index', 'table','dict','laydate','util','element'], function(){ var $ = layui.$,table = layui.table,form = layui.form; var dict = layui.dict; var laydate = layui.laydate; var admin = layui.admin; var util = layui.util; var element = layui.element; element.on('tab(myTaskTabs)',function (data) { var index = data.index; var urlArr = [ 'myTaskTodoList.jsp', 'myCreateTaskList.jsp', 'myTaskDoneList.jsp', 'myTaskList.jsp', ]; layui.$("iframe[name='iframe" + index + "']").attr("src",urlArr[index]); }) }); </script>
即動態修改 iframe 的src ,頁面會從新加載。jsp