layuiadmin新建tabs标签页,点击保存,打开新的标签页并刷新

用的layuiamin前端框架

需求:新增的页面为一个标签页,保存后,需要刷新列表

1、新建customMethod.js文件,自定义自己的方法

复制代码
layui.define(function (exports) {
  var $ = layui.$
  var customMethod = {
    // 表单点击保存后,新表单当前页,并新开标签页刷新
    reload: function (link,title) {
      top.layui.index.openTabsPage(link, title); //打开新标签页
      setTimeout(function () {
        // 刷新当前页面
        location.reload();
        // 刷新新开标签页
        var src = $("#LAY_app_body .layadmin-tabsbody-item.layui-show>iframe", parent.document).attr("src")
        // console.log("122", src);
        $("#LAY_app_body .layadmin-tabsbody-item.layui-show>iframe", parent.document).attr("src", src)
      }, 100)
    },

    init: function (some) {
      console.log("其它公用方法")
    },

  };

  exports('customMethod', customMethod);
})

2、找到config.js文件,引入自定义方法

//扩展的第三方模块

,extend: [

'customMethod',//公用文件

'echarts', //echarts 核心包

'echartsTheme' //echarts 主题

]

3、在需要使用html页面use模块

复制代码
<script>

    layui.config({

      base: '../../layuiadmin/' //静态资源所在路径

    }).extend({

      index: 'lib/index' //主入口模块

    }).use(['index', 'console','customMethod'], function () {
      var $ = layui.$
        , setter = layui.setter
        , admin = layui.admin
        , form = layui.form
        , router = layui.router()
        , search = router.search
        , customMethod = layui.customMethod;
        console.log("当前")
      $("#aaa").click(function () {
        customMethod.reload("home/homepage1.html","主页一")
      })
      
    //在提交保存的地方
  //customMethod.reload("{:url('ditch/channel/channelList')}", "渠道列表");//打开列表

    });

  </script>

4、

相关推荐
kyle~1 天前
C++---value_type 解决泛型编程中的类型信息获取问题
java·开发语言·c++
小飞侠在吗1 天前
vue props
前端·javascript·vue.js
NiNi_suanfa1 天前
【Qt】Qt 批量修改同类对象
开发语言·c++·qt
小糖学代码1 天前
LLM系列:1.python入门:3.布尔型对象
linux·开发语言·python
DsirNg1 天前
页面栈溢出问题修复总结
前端·微信小程序
小徐_23331 天前
uni-app 也能远程调试?使用 PageSpy 打开调试的新大门!
前端·微信小程序·uni-app
Data_agent1 天前
1688获得1688店铺详情API,python请求示例
开发语言·爬虫·python
大怪v1 天前
【Virtual World 03】上帝之手
前端·javascript
妖灵翎幺1 天前
C++ 中的 :: 操作符详解(一切情况)
开发语言·c++·ide
Halo_tjn1 天前
虚拟机相关实验概述
java·开发语言·windows·计算机