Button 本页跳转

develop
就眠仪式 2021-02-20 17:11:38 +08:00
parent 752d3b22f4
commit 490fead502
3 changed files with 68 additions and 20 deletions

View File

@ -1,4 +1,4 @@
layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame', 'theme'], layui.define(['table', 'jquery', 'element', 'yaml', 'form', 'tab', 'menu', 'frame', 'theme'],
function(exports) { function(exports) {
"use strict"; "use strict";
@ -40,18 +40,16 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
} }
this.readConfig = function() { this.readConfig = function() {
if(configType === "yml"){ if (configType === "yml") {
return yaml.load(configPath); return yaml.load(configPath);
} } else {
else
{
let data; let data;
$.ajax({ $.ajax({
url:configPath, url: configPath,
type:'get', type: 'get',
dataType:'json', dataType: 'json',
async: false, async: false,
success:function(result){ success: function(result) {
data = result; data = result;
} }
}) })
@ -93,7 +91,8 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
refreshA.addClass("layui-anim-rotate"); refreshA.addClass("layui-anim-rotate");
refreshA.addClass("layui-anim-loop"); refreshA.addClass("layui-anim-loop");
refreshA.addClass("layui-icon-loading"); refreshA.addClass("layui-icon-loading");
bodyTab.refresh(400); if (param.tab.muiltTab) bodyTab.refresh(400);
else bodyFrame.refresh(400);
setTimeout(function() { setTimeout(function() {
refreshA.addClass("layui-icon-refresh-1"); refreshA.addClass("layui-icon-refresh-1");
refreshA.removeClass("layui-anim"); refreshA.removeClass("layui-anim");
@ -121,12 +120,12 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
title: param.tab.index.title, title: param.tab.index.title,
close: false close: false
}], }],
success: function(id){ success: function(id) {
if(param.tab.session){ if (param.tab.session) {
setTimeout(function(){ setTimeout(function() {
sideMenu.selectItem(id); sideMenu.selectItem(id);
bodyTab.positionTab(); bodyTab.positionTab();
},500) }, 500)
} }
} }
}); });
@ -323,7 +322,7 @@ layui.define(['table', 'jquery', 'element', 'yaml','form', 'tab', 'menu', 'frame
}); });
}); });
function bottomTool(){ function bottomTool() {
return "<button id='closeTheme' style='position: absolute;bottom: 20px;left: 20px;' class='pear-btn'>关闭</button>" return "<button id='closeTheme' style='position: absolute;bottom: 20px;left: 20px;' class='pear-btn'>关闭</button>"
} }

View File

@ -39,6 +39,21 @@ layui.define(['table', 'jquery', 'element'], function (exports) {
} }
} }
pearFrame.prototype.changePageByElement = function(elem,url,title,loading){
if(loading){
var loading = $("#"+elem).find(".pear-frame-loading");
loading.css({display:'block'});
}
$("#"+elem+" iframe").attr("src",url);
$("#"+elem+" .title").html(title);
if(loading){
var loading = $("#"+elem).find(".pear-frame-loading");
setTimeout(function(){
loading.css({display:'none'});
},800)
}
}
pearFrame.prototype.refresh = function (time) { pearFrame.prototype.refresh = function (time) {
if(time!=false){ if(time!=false){
var loading = $("#"+this.option.elem).find(".pear-frame-loading"); var loading = $("#"+this.option.elem).find(".pear-frame-loading");

View File

@ -233,6 +233,36 @@
</div> </div>
</div> </div>
</div> </div>
<div class="layui-col-md12">
<div class="layui-card">
<div class="layui-card-header">
Load 手动
</div>
<div class="layui-card-body">
<button class="pear-btn pear-btn-primary" to> 本页跳转 </button>
</div>
</div>
</div>
<div class="layui-col-md12">
<div class="layui-collapse">
<div class="layui-colla-item">
<h2 class="layui-colla-title">显示代码</h2>
<div class="layui-colla-content">
<pre class="layui-code" lay-encode="true">
layui.use(["jquery"], function() {
var $ = layui.jquery;
$("[to]").click(function(){
top.layui.frame.changePageByElement("content","http://www.baidu.com","百度一下",true)
})
})
</pre>
</div>
</div>
</div>
</div>
</div> </div>
<script src="../../component/layui/layui.js"></script> <script src="../../component/layui/layui.js"></script>
<script src="../../component/pear/pear.js"></script> <script src="../../component/pear/pear.js"></script>
@ -268,6 +298,10 @@
popup.failure("已停止"); popup.failure("已停止");
}); });
}) })
$("[to]").click(function(){
top.layui.frame.changePageByElement("content","http://www.baidu.com","百度一下",true)
})
}) })
</script> </script>
</body> </body>