vue传值

<template>
<div class="mian">
<div class="mian-left">
<ul class="lie">
<li v-for="(temp,index) in list" @click="clickMe(temp.cid)">{{temp.title}}</li>
</ul>
</div>
<div class="mian-right">
<div class="fu-right" >
<div class="biaoti" v-for="(temp,index) in data" v-if="data!='没有数据'">
{{temp.title}}
<div class="mian-content">
<div class="items" v-for="(item,index) in data[index].goods">
<img :src="item.image" class="tu"/>
<p class="wenzi">{{item.title}}</p>
</div>
</div>
</div>
<div class="biaoti" v-else="data=='没有数据'" style="text-align:center">
<p v-if="index==0">暂无数据请等待数据君的到来</p>

</div>
</div>
</div>
</div>
</template>

<script>
import axios from 'axios'
export default {
data(){
return{
list:[],
data:[],
good:[]
}
},
created(){
axios.get('http://vueshop.glbuys.com/api/home/category/menu?token=1ec949a15fb709370f ').then(rec=>{
this.list=rec.data.data
})
axios.get('http://vueshop.glbuys.com/api/home/category/show?cid=492&token=1ec949a15fb709370f').then(rec=>{
this.data=rec.data.data
})
},
methods:{
clickMe(index){
axios.get('http://vueshop.glbuys.com/api/home/category/show?cid='+index+'&token=1ec949a15fb709370f').then(rec=>{
this.data=rec.data.data
console.log(rec.data.data)
})
}
}
}
</script>

<style scoped>
.mian{
width: 100%;
height: 90%;
clear: both;
overflow: hidden;
background-color:#EFEFEF;
margin-top: 2.5rem;
}
.mian-left{
width: 23%;
height: 622px;
background: #FFFFFF;
float: left;
margin-right: 3%; } .lie{ width: 100%; height: 100%; position: relative; z-index: 1; overflow:auto; } .lie li{ width: 100%; height: 2rem; line-height: 2rem; text-align: center; border-bottom: 1px solid #EFEFEF; font-size: 0.7rem; } .lie li:hover{ color:red; } .mian-right{ width: 74%; height: 607px; float: left; overflow: hidden; } .fu-right{ width: 100%; height: 100%; position: relative; z-index: 1; overflow:auto; } .biaoti{ width: 95%; height: auto; font-size: 0.7rem; margin-top: 0.7rem; clear: both; } .mian-content{ width: 95%; height: auto; background: #FFFFFF; margin-top: 0.5rem; overflow: hidden; padding-bottom: 0.8rem; background-color: white } .items{ width: 33%; height:4rem; float: left; margin-top: 0.5rem; text-align:center; } .tu{ width: 70%; height: 3rem; overflow: hidden; margin: 0 auto; } .wenzi{ width: 100%; height: 1rem; overflow: hidden; /*white-space: nowrap;把文本限制在一行*/ white-space: nowrap; /*省略号text-overflow: ellipsis;*/ text-overflow: ellipsis; font-size: 0.6rem; text-align: center; line-height: 1rem; }</style>

猜你喜欢

转载自www.cnblogs.com/wzxwzxwzx/p/9646635.html
今日推荐