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>
  • 9
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值