<template>
<div class="warpper">
<div class="header">
<div class="left font color" data-index="0" @mouseover="change" ref="index0">left</div>
<div class="right font" data-index="1" @mouseover="change" ref="index1">right</div>
</div>
<div class="body">
<ul>
<li><a :href="data1"><img :src="data2" alt=""><span>{{data3}}</span></a></li>
<li><a :href="data1"><img :src="data2" alt=""><span>{{data3}}</span></a></li>
<li><a :href="data1"><img :src="data2" alt=""><span>{{data3}}</span></a></li>
<li><a :href="data1"><img :src="data2" alt=""><span>{{data3}}</span></a></li>
<li><a :href="data1"><img :src="data2" alt=""><span>{{data3}}</span></a></li>
<li><a :href="data1"><img :src="data2" alt=""><span>{{data3}}</span></a></li>
</ul>
</div>
</div>
</template>
<script>
export default {
name: "test",
data(){
return{
data1:'www.baidu.com',
data2:'http://photocdn.sohu.com/20151127/mp44855242_1448611696691_3.jpeg',
data3:'左侧',
}
},
methods:{
tz(){
this.$router.push({
path: '/anliku',
})
},
/*切换*/
change(e){
/*判断是左是右*/
if (e.target.dataset.index == '0') {
this.$refs.index0.classList.add("color");
this.$refs.index1.classList.remove("color");
/*这里掉左侧接口获取数据*/
this.data1='https://www.baidu.com'
this.data2='http://photocdn.sohu.com/20151127/mp44855242_1448611696691_3.jpeg'
this.data3='左侧'
}else{
this.$refs.index1.classList.add("color");
this.$refs.index0.classList.remove("color");
/*这里掉右侧接口获取数据*/
this.data1='https://www.toutiao.com'
this.data2='http://www.mms591.com/www.mms591.com-photo/2013041914/1-130419144U1.jpg'
this.data3='右侧'
}
}
}
}
</script>
<style scoped>
*{
margin: 0;
padding: 0;
}
.warpper{
width: 550px;
height: 450px;
border: 1px solid #000;
margin-left: 20px;
margin-top: 20px;
background-color: #fff;
}
.header{
height: 15%;
border-bottom: 1px solid black;
display: flex;
box-sizing: border-box;
}
.font:before {
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
margin-right: -0.25em;
}
.font{
text-align: center;
font-size: 26px;
font-weight: bold;
width: 50%;
cursor: pointer;
}
.color{
background-color: #e0e0e0;
color: white;
}
/*.font:hover{
background-color: #e0e0e0;
color: white;
}*/
.left{
border-right: 1px solid black;
}
.body{
height: 85%;
}
ul {
height: 100%;
padding: 10px;
box-sizing: border-box;
}
li {
list-style: none;
width: calc((100% - 20px) / 3);
height: calc((100% - 10px) / 2);
border: 1px solid #000;
box-sizing: border-box;
float: left;
margin-right: 10px;
margin-bottom: 10px;
text-align: center;
}
li:nth-child(3n){
margin-right: 0;
}
li:nth-child(n+3){
margin-bottom: 0;
}
img{
width: 100%;
height: 90%;
}
a{
display: flex;
height: 100%;
flex-direction: column;
justify-content: space-between;
}
</style>
12-22
1798