layui pearadmin 刷新指定Tab标签页面数据
/** * 刷新指定tab页id的数据-一般为列表页面 * @param {string|number} tabId tab页id * 示例 refreshTabData(510); 或 refreshTabData('510');均可 * tabId 可通过右键审查-左侧菜单元素得到 比如 内容提报 - 稿件管理的tabId=510 */ this.refreshTabData = function (tabId) { tabId = tabId + '';//兼容tabId填写数字类型,自动转为字符串 $('.layui-tab-content').find('.layui-tab-item').find('iframe').each(function () { if ($(this).attr('id') == tabId) { const iframeDoc = this.contentDocument || this.contentWindow.document; $(iframeDoc).find('div[lay-event="refresh"]').click(); } }); }
//使用示例
$.ajax({ url: '/xg/article/store', type: 'POST', dataType: 'json', contentType: 'application/json', data: JSON.stringify(vm.formData), success: function (res) { if (res.success) { layer.msg('保存成功', { icon: 1 ,time:3000}); setTimeout(() => { //layui刷新指定页面 - 自己写的方法 top.layui.admin.refreshTabData(510); //layui关闭当前标签页面 top.layui.tab.delCurrentTabByElem('content',()=>{}) }, 3500); } else { layer.msg(res.msg, { icon: 5 }); } }, error: function (err) { layer.msg('请求失败', { icon: 5 }); } });