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、

相关推荐
子兮曰20 小时前
OpenClaw入门:从零开始搭建你的私有化AI助手
前端·架构·github
吴仰晖20 小时前
使用github copliot chat的源码学习之Chromium Compositor
前端
1024小神20 小时前
github发布pages的几种状态记录
前端
灰子学技术1 天前
go response.Body.close()导致连接异常处理
开发语言·后端·golang
二十雨辰1 天前
[python]-AI大模型
开发语言·人工智能·python
不像程序员的程序媛1 天前
Nginx日志切分
服务器·前端·nginx
Yvonne爱编码1 天前
JAVA数据结构 DAY6-栈和队列
java·开发语言·数据结构·python
Re.不晚1 天前
JAVA进阶之路——无奖问答挑战1
java·开发语言
Daniel李华1 天前
echarts使用案例
android·javascript·echarts
北原_春希1 天前
如何在Vue3项目中引入并使用Echarts图表
前端·javascript·echarts