12345678910111213141516171819 |
- // 树状结构构建插件
- const last = {
- install (Vue) {
- Vue.prototype.$last = function(options) {
- const last = item => {
- const isCode = options.menus.filter(j => j.code == item);
- if (isCode.length > 0) {
- const children = options.menus.filter(k => k.parentCode == isCode[0]?.code);
- if (children.length > 0) return last(children[0]?.code);
- }
- return isCode[0];
- };
- const item = last(options.code);
- sessionStorage.setItem('code', item.code);
- return item;
- };
- }
- };
- export default last;
|