e5b57447
杨鑫
'分包问卷'
|
1
2
3
4
5
6
7
|
import store from '@/store'
const { body } = document
const WIDTH = 992 // refer to Bootstrap's responsive design
export default {
watch: {
|
d64cd58f
wesley88
上传验收小程序
|
8
|
$route (route) {
|
e5b57447
杨鑫
'分包问卷'
|
9
10
11
12
13
|
if (this.device === 'mobile' && this.sidebar.opened) {
store.dispatch('app/closeSideBar', { withoutAnimation: false })
}
}
},
|
d64cd58f
wesley88
上传验收小程序
|
14
|
beforeMount () {
|
e5b57447
杨鑫
'分包问卷'
|
15
16
|
window.addEventListener('resize', this.$_resizeHandler)
},
|
d64cd58f
wesley88
上传验收小程序
|
17
|
beforeDestroy () {
|
e5b57447
杨鑫
'分包问卷'
|
18
19
|
window.removeEventListener('resize', this.$_resizeHandler)
},
|
d64cd58f
wesley88
上传验收小程序
|
20
|
mounted () {
|
e5b57447
杨鑫
'分包问卷'
|
21
22
23
24
25
26
27
28
29
|
const isMobile = this.$_isMobile()
if (isMobile) {
store.dispatch('app/toggleDevice', 'mobile')
store.dispatch('app/closeSideBar', { withoutAnimation: true })
}
},
methods: {
// use $_ for mixins properties
// https://vuejs.org/v2/style-guide/index.html#Private-property-names-essential
|
d64cd58f
wesley88
上传验收小程序
|
30
|
$_isMobile () {
|
e5b57447
杨鑫
'分包问卷'
|
31
32
33
|
const rect = body.getBoundingClientRect()
return rect.width - 1 < WIDTH
},
|
d64cd58f
wesley88
上传验收小程序
|
34
|
$_resizeHandler () {
|
e5b57447
杨鑫
'分包问卷'
|
35
36
37
38
39
40
41
42
43
44
45
|
if (!document.hidden) {
const isMobile = this.$_isMobile()
store.dispatch('app/toggleDevice', isMobile ? 'mobile' : 'desktop')
if (isMobile) {
store.dispatch('app/closeSideBar', { withoutAnimation: true })
}
}
}
}
}
|