一、layui菜单及选项卡只有第一次点击会刷新,重复点击是从cache中读取,实际生产环境中这种方式显得很累赘。
在layui的底层js,也就是admin.js中找到监听tab切换的tabsBodyChange方法,添加如下配置即可完美解决:
P.tabsBody(e).children("iframe").attr("src", P.tabsBody(e).children("iframe").attr("src")),
二、附完整js:
tabsBodyChange: function (e, a) {
a = a || {}, P.tabsBody(e).addClass(d).siblings().removeClass(d), P.tabsBody(e).children("iframe").attr("src", P.tabsBody(e).children("iframe").attr("src")),F.rollPage("auto", e), layui.event.call(this, n.MOD_NAME, "tabsPage({*})", {
url: a.url,
text: a.text
})
},