<template><view class='pics'><scroll-view class='left' scroll-y><view :class="active === index?'active':''" v-for='(item,index) in cates' :key='item.id' @click="leftClickHandle(index)">{{item.title}}</view></scroll-view></view></template><script>export default {data() {return {cates:[],active:0};},methods:{async getPicsCate(){const res = await this.$myRequest({url:'/api/getimgcategory'})this.cates = res.data.message},leftClickHandle(index){ //点击一下就变成高亮this.active = index}},onLoad(){this.getPicsCate()}}</script><style lang="scss">page{height:100%;}.pics{height:100%;.left{width:200rpx;height:100%;border-right:1px solid #eee;view{height:60px;line-height:60px;color:#333;text-align: center;font-size:35rpx;border-top:1px solid #eee;}.active{background: $shop-color;color:#fff;}}}</style>

一定要注意函数绑定以及动态绑定。data数据的应用
