点击菜单

1. 当前项高亮
2. 右侧切换到对应项
This commit is contained in:
jqtmviyu@gmail.com 2021-02-25 10:42:23 +08:00
parent ce53c58f68
commit 25610727b7

View File

@ -9,7 +9,7 @@
<view class="category_content">
<!-- 2.1 左列表: 大家电,热门推荐,海外购... -->
<view class="menu">
<view class="menu_list" v-for="item in menu" :key="item">{{item}}</view>
<view @tap="onMenuTap(index)" :class="['menu_list', menuCurrent===index?'active':'']" v-for="(item,index) in menus" :key="item">{{item}}{{index}}</view>
</view>
<!-- 2.2 右列表: 电视,空调... -->
<view class="category_list">
@ -30,16 +30,17 @@
</template>
<script>
// , , data,
let categoryData = {}
export default {
data(){
return{
//
menu:[],
menus:[],
//
menuCurrent: 0,
//
goods: []
goods: [],
}
},
onLoad(){
@ -49,13 +50,20 @@ export default {
//
async getCategories(){
const { message } = await this.$u.api.getCategories()
//
categoryData = message
console.log(message);
this.menu = message.map(v=>(v.cat_name))
console.log(this.menu)
console.log(categoryData);
//
this.menus = message.map(v=>(v.cat_name))
// console.log(this.menu)
//
this.goods = message[this.menuCurrent].children
console.log(this.goods);
},
onMenuTap(menuCurrent) {
this.menuCurrent = menuCurrent
this.goods = categoryData[menuCurrent].children
}
}
}