<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.up {
height: 500px;
background-color: red;
}
.down {
height: 300px;
background-color: green;
}
.transition-dom {
transition: all .2s linear 0s;
}
</style>
<script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>
<!-- 引入样式 -->
<link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
<!-- 引入组件库 -->
<script src="https://unpkg.com/element-ui/lib/index.js"></script>
</head>
<body>
<div id="app">
<el-row :gutter="20">
<el-col :span="18">
<el-row>
<div style="height:100%;background-color: black;">
1
</div>
</el-row>
<el-row>
<div style="height:100%;background-color: black;">
2
</div>
</el-row>
</el-col>
<el-col :span="6">
<el-row>
<el-col>
<div class="up transition-dom" ref="boxUp" @click="funAnimateUp"></div>
</el-col>
</el-row>
<el-row>
<el-col>
<div class="down transition-dom" ref="boxDown" @click="funAnimateDown"></div>
</el-col>
</el-row>
</el-col>
</el-row>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Hello Vue!',
headerOpenUp: false,
headerOpenDown: false
},
methods: {
// 商家详情的展开与显示
funAnimateUp() {
if (this.headerOpenUp) {
this.$refs.boxUp.style.height = '500px'
this.$refs.boxDown.style.height = '300px'
} else {
this.$refs.boxUp.style.height = '800px'
this.$refs.boxDown.style.height = 0
}
this.headerOpenUp = !this.headerOpenUp
},
funAnimateDown() {
if (this.headerOpenDown) {
this.$refs.boxUp.style.height = '500px'
this.$refs.boxDown.style.height = '300px'
} else {
this.$refs.boxUp.style.height = 0
this.$refs.boxDown.style.height = '800px'
}
this.headerOpenDown = !this.headerOpenDown
}
}
})
</script>
</body>
</html>