效果图如下

以下代码基于Vue2
<template>
<div class="container">
<div class="left-section" :style="{ width: widthLeft + 'vw' }" @click="toggleRightSection"></div>
<div class="right-section" :style="{ width: (100 - widthLeft) + 'vw' }"></div>
</div>
</template>
<script>
export default {
data() {
return {
widthLeft: 60
};
},
methods: {
toggleRightSection() {
if (this.widthLeft === 60) {
this.widthLeft = 100;
} else {
this.widthLeft = 60;
}
}
}
};
</script>
<style>
.container {
display: flex;
height: 80vh;
overflow: hidden;
}
.left-section {
transition: width 0.3s ease-in-out;
background-color: #e0e0e0;
padding: 20px;
}
.right-section {
transition: width 0.3s ease-in-out;
background-color: #c0c0c0;
}
</style>
- 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