1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
| <template>
| <div id="app">
| <router-view />
| </div>
| </template>
|
| <script>
| export default {
| name: 'App',
| data() {
| return {
| windowWidth: window.innerWidth,
| isCollapse: false
| }
| },
| watch: {
| windowWidth(newWidth) {
| // 当窗口宽度小于某个值时,可以触发折叠
| if (newWidth < 1200 && !this.isCollapse) {
| this.isCollapse = true
| this.$store.commit('SET_ISFOLD', true)
| } else if (newWidth >= 1200 && this.isCollapse) {
| this.isCollapse = false
| this.$store.commit('SET_ISFOLD', false)
| }
| }
| },
| created() {
| // 初始化时检查窗口大小
| this.handleResize()
| },
| mounted() {
| // 监听窗口大小变化
| window.addEventListener('resize', this.handleResize)
| },
| beforeDestroy() {
| // 移除监听
| window.removeEventListener('resize', this.handleResize)
| },
| methods: {
| handleResize() {
| this.windowWidth = window.innerWidth
| }
| },
| }
| </script>
|
| <style lang="less">
| ::-webkit-scrollbar {
| display: none;
| }
|
| html,
| body,
| #app {
| height: 100%;
| margin: 0;
| padding: 0;
| background-color: rgb(245, 245, 245);
| }
|
| .selected {
| color: #049C9A !important;
| }
| </style>
|
|