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、

相关推荐
Hical_W1 天前
C++ 也能优雅写 Web?5 分钟用 Hical 搭建 REST API
开发语言·c++·github
历程里程碑1 天前
55 Linux epoll高效IO实战指南
java·linux·服务器·开发语言·前端·javascript·c++
何包蛋H1 天前
Java并发编程核心:JUC、AQS、CAS 完全指南
java·开发语言
Mapmost1 天前
【Mapmost 渲染指北】利用LUT快速构建场景色调
前端
踩着两条虫1 天前
VTJ:核心概念
前端·低代码·ai编程
Moment1 天前
作为前端,如果使用 Langgraph 实现第一个 Agent
前端·javascript·后端
相信神话20211 天前
第六章:迷你项目:「投壶」单关卡小游戏
前端
云深麋鹿1 天前
C++ | 容器stack&queue
开发语言·c++
比老马还六1 天前
element-ui,使用el-table时,type=“expand“和fixed一起使用坑
开发语言·javascript·ui
Xiu Yan1 天前
Java 转 C++ 系列:STL容器之list
java·开发语言·数据结构·c++·stl·list·visual studio