寫法 1:將函數存入變量內,子類頁面調用
父頁面 var _tools = { //方法1 refresh:function(){ layui.table.reload('dg',{ where : layui.$.form.val('fm'), page : { curr : 1 } }); }, //方法2 refreshTree :function (){ console.log(2); } } window.tools = _tools;
parent.tools.refresh();//子頁面直接調用即可 parent.tools.refreshTree();
寫法2:子類頁面點擊父頁面按鈕觸發方法
parent.layui.$('#refresh').click();