vue中warning_VUE格式化選單欄
阿新 • • 發佈:2021-01-02
技術標籤:vue中warning
export const isNotNullORBlank = (...args)=> { for (var i = 0; i < args.length; i++) { var argument = args[i]; if (argument == null || argument == '' || argument == undefined) { Message.warning({message: '資料不能為空!'}) return false; } } return true; } export const initMenu = (router, store)=> { if (store.state.routes.length > 0) { return; } getRequest("/config/sysmenu").then(resp=> { if (resp && resp.status == 200) { var fmtRoutes = formatRoutes(resp.data); //載入到router中、 router.addRoutes(fmtRoutes); store.commit('initMenu', fmtRoutes); store.dispatch('connect'); } }) } export const formatRoutes = (routes)=> { let fmRoutes = []; routes.forEach(router=> { let { path, component, name, meta, iconCls, children } = router; if (children && children instanceof Array) { children = formatRoutes(children); } let fmRouter = { path: path, //將返回的字串轉化為元件 component(resolve){ if (component.startsWith("Home")) { require(['../components/' + component + '.vue'], resolve) } else if (component.startsWith("Emp")) { require(['../components/emp/' + component + '.vue'], resolve) } else if (component.startsWith("Per")) { require(['../components/personnel/' + component + '.vue'], resolve) } else if (component.startsWith("Sal")) { require(['../components/salary/' + component + '.vue'], resolve) } else if (component.startsWith("Sta")) { require(['../components/statistics/' + component + '.vue'], resolve) } else if (component.startsWith("Sys")) { require(['../components/system/' + component + '.vue'], resolve) } }, name: name, iconCls: iconCls, meta: meta, children: children }; fmRoutes.push(fmRouter); }) return fmRoutes; }