Menu.js 832 B

1234567891011121314151617181920212223242526272829303132
  1. export default class Menu {
  2. constructor(Dcat) {
  3. this.bindClick();
  4. }
  5. // 菜单点击选中效果
  6. bindClick() {
  7. if (! $('.main-sidebar .sidebar').length) {
  8. return;
  9. }
  10. // 滚动条优化
  11. new PerfectScrollbar('.main-sidebar .sidebar');
  12. let $content = $('.main-menu-content'),
  13. $items = $content.find('li'),
  14. $hasSubItems = $content.find('li.has-treeview');
  15. $items.find('a').click(function () {
  16. let href = $(this).attr('href');
  17. if (! href || href === '#') {
  18. return;
  19. }
  20. $items.find('.nav-link').removeClass('active');
  21. // $hasSubItems.removeClass('menu-open');
  22. $(this).addClass('active')
  23. });
  24. }
  25. }