last.js 529 B

1234567891011121314151617
  1. // 树状结构构建插件
  2. const last = {
  3. install (Vue) {
  4. Vue.prototype.$last = function(options) {
  5. const last = item => {
  6. const isCode = options.menus.filter(j => j.code == item);
  7. const children = this.menusall.filter(k => k.parentCode == isCode[0]?.code);
  8. if (children.length > 0) return last(children[0]?.code);
  9. return isCode[0];
  10. };
  11. const item = last(options.code);
  12. sessionStorage.setItem('code', item.code);
  13. return item;
  14. };
  15. }
  16. };
  17. export default last;