From b422a8464dd40a90662cfefc7100ae4427193228 Mon Sep 17 00:00:00 2001 From: liyang <1711467488@qq.com> Date: Tue, 3 Jul 2018 10:04:54 +0800 Subject: [PATCH] no message Former-commit-id: c716d8898113e6e31cf821e142321676a0044e9b [formerly c716d8898113e6e31cf821e142321676a0044e9b [formerly c716d8898113e6e31cf821e142321676a0044e9b [formerly c716d8898113e6e31cf821e142321676a0044e9b [formerly 22c749da297ba2d409e49f0d54a74b2e7d0fe1e7 [formerly de11ac64f89ebc3bb1ce79acdf1c36b15bfd2ecb]]]]] Former-commit-id: 1777666f0ed7b13e47fd19cbde226c581e39344c Former-commit-id: 99506973b138f37589bcc483bba01969995f2ee0 Former-commit-id: a3ea8c97f1a245fc618de0b7eacd108f66abd928 [formerly ef53f6c834a5e7d47b86134952437996cae2f177] Former-commit-id: 50e3b066a1815959ed460976fcf4662e59a5af4a Former-commit-id: abe5f4bc9e84aa19d4a90b7b3b6d2c8e7ff79e17 Former-commit-id: 2f478f3b022f2ef178580b91bf3681b0179c7259 Former-commit-id: c1091d94bd8785464f54768498cdaee47e0b8987 Former-commit-id: 95872751e37b9b50513ba8c9f6898a4e9b9530b4 --- .../components/-menu-side/index.vue | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/src/components/core/d2-layout-main/components/-menu-side/index.vue b/src/components/core/d2-layout-main/components/-menu-side/index.vue index 673e1e6f..b76dbb3e 100644 --- a/src/components/core/d2-layout-main/components/-menu-side/index.vue +++ b/src/components/core/d2-layout-main/components/-menu-side/index.vue @@ -52,6 +52,13 @@ export default { } }, watch: { + // 折叠和展开菜单的时候销毁 better scroll + collapse (val) { + this.scrollDestroy() + setTimeout(() => { + this.scrollInit() + }, 500) + }, '$route.matched': { handler (val) { const path = val[0].path @@ -68,13 +75,26 @@ export default { } }, mounted () { - this.BS = new BScroll(this.$el, { - mouseWheel: true, - scrollbar: { - fade: true, - interactive: false + this.scrollInit() + }, + beforeDestroy () { + this.scrollDestroy() + }, + methods: { + scrollInit () { + this.BS = new BScroll(this.$el, { + mouseWheel: true, + scrollbar: { + fade: true, + interactive: false + } + }) + }, + scrollDestroy () { + if (this.BS) { + this.BS.destroy() } - }) + } } }