no message
Former-commit-id: f48834fbf8a3dd0a175694f722797153cd7268d6 [formerly f48834fbf8a3dd0a175694f722797153cd7268d6 [formerly f48834fbf8a3dd0a175694f722797153cd7268d6 [formerly f48834fbf8a3dd0a175694f722797153cd7268d6 [formerly 257001ecfa6474a3768a67ea0f134062f7f14394 [formerly da3a620cf3099acab4993873244c7f36d3340bae]]]]] Former-commit-id: 5eca38c66b440f042bcedd69b5cfa3e522b52914 Former-commit-id: f5e1b9c1f3cb1681d39317d0111f894c854d1859 Former-commit-id: 0e1470154ae7e31807c8c99a4143837b8864dd2f [formerly e3f2ff894738e9a6b2f39a32ba1260ec19eb9a65] Former-commit-id: 39f38e5b07abd827e112e1bd338dbb7a54d5358f Former-commit-id: 2efb6a3e1284d36ab66457f61290199f1d1e610b Former-commit-id: 797ccc66958f7c688d0e8411ee8f7e75f7ec7b18 Former-commit-id: 94ece070f41cf36fcf05b4096f1855bec34c49f2 Former-commit-id: 0ad1f1b3ae30bbe002e4d491782e1c62b396bf88
This commit is contained in:
@@ -20,6 +20,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { throttle } from 'lodash'
|
||||
import { mapState } from 'vuex'
|
||||
import menuMixin from '../mixin/menu'
|
||||
import d2LayoutMainMenuItem from '../components/menu-item/index.vue'
|
||||
@@ -44,7 +45,8 @@ export default {
|
||||
isScroll: false,
|
||||
scrollWidth: 0,
|
||||
contentWidth: 0,
|
||||
currentTranslateX: 0
|
||||
currentTranslateX: 0,
|
||||
throttledCheckScroll: null
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -68,10 +70,8 @@ export default {
|
||||
this.currentTranslateX = this.contentWidth - this.scrollWidth
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
const checkScroll = () => {
|
||||
},
|
||||
checkScroll () {
|
||||
let contentWidth = this.$refs.content.clientWidth
|
||||
let scrollWidth = this.$refs.scroll.clientWidth
|
||||
if (this.isScroll) {
|
||||
@@ -105,14 +105,18 @@ export default {
|
||||
})
|
||||
}
|
||||
}
|
||||
},
|
||||
mounted () {
|
||||
// 初始化判断
|
||||
checkScroll()
|
||||
|
||||
// 默认判断父元素和子元素的大小,以确定初始情况是否显示滚动
|
||||
this.checkScroll()
|
||||
// 全局窗口变化监听,判断父元素和子元素的大小,从而控制isScroll的开关
|
||||
window.onresize = () => {
|
||||
checkScroll()
|
||||
}
|
||||
this.throttledCheckScroll = throttle(this.checkScroll, 300)
|
||||
window.addEventListener('resize', this.throttledCheckScroll)
|
||||
},
|
||||
beforeDestroy () {
|
||||
// 取消监听
|
||||
window.removeEventListener('resize', this.throttledCheckScroll)
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
Reference in New Issue
Block a user