const setChildrenSession = { install (Vue) { Vue.prototype.$setChildrenSession = function(options) { const children = items => { const childrenList = options.menus.filter(j => items.code == j.parentCode && j.isshow).map(e => children(e)); if (childrenList.length > 0) { return { ...items, children: childrenList }; } return { ...items }; }; const list = options.menus.filter(e => e.code == options.iscode).map(e => children(e)); return list[0]; }; } }; export default setChildrenSession;