Merge branch 'hotfix/addEventListener' into develop
Former-commit-id: 5fcb1ecd497bf704b6d399bd8c482389fb3ce730 [formerly 5fcb1ecd497bf704b6d399bd8c482389fb3ce730 [formerly 5fcb1ecd497bf704b6d399bd8c482389fb3ce730 [formerly 5fcb1ecd497bf704b6d399bd8c482389fb3ce730 [formerly fdb86e9b61a2f5dc8a8d5ae740c0d877d7b348bc [formerly b03dca12c7bc0618bfe993a8f5f90a1895a0d846]]]]] Former-commit-id: dcd695d8f787f13e4e90aa61e72cd40361e73f7f Former-commit-id: 5482d0aeed3a59b3f3f4a7c09a46b6f929f2a074 Former-commit-id: 415767464c9ed461bada45ba3065629e3efe55c5 [formerly 535d2a56907ffeb2b3e88e467ed034f71487c8d6] Former-commit-id: cdb6b96bd912c662e24e3ac3fdb27851370a7a5b Former-commit-id: 81bb54861218b39d1fd7440de956770ec28cf1bb Former-commit-id: ae0384aa6638d7e488c04e0f439ccb7d0198c63a Former-commit-id: 10816c166fc765bf932bc4bc98e3b875d7396a80 Former-commit-id: f6cc971baada90fa1bbfa2d0307cf452877a719f
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "d2-admin",
|
||||
"version": "1.4.7",
|
||||
"version": "1.4.8",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"serve": "vue-cli-service serve --open",
|
||||
|
||||
@@ -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