优化一下:当菜单未关闭时点击×,先关闭菜单再关闭侧边栏。
//只需要在Sidebar的关闭函数里写:
if(this.menubar.state === "hasOpen"){ this.menubar.currentOpenTarget.className = 'nav-content'; this.menubar.currentOpenTarget.style.top = 0; this.menubar.currentOpenTarget.style.left = 35 + 'px'; this.menubar.currentOpenTarget.classList.add('menuContent-move-left'); this.menubar.state = 'allClose'; }