scroll-view解决切换置顶
This commit is contained in:
parent
a8082b2761
commit
3a2ad8e278
@ -12,7 +12,7 @@
|
|||||||
<view @tap="onMenuTap(index)" :class="['menu_list', menuCurrent===index?'active':'']" v-for="(item,index) in menus" :key="item">{{item}}</view>
|
<view @tap="onMenuTap(index)" :class="['menu_list', menuCurrent===index?'active':'']" v-for="(item,index) in menus" :key="item">{{item}}</view>
|
||||||
</view>
|
</view>
|
||||||
<!-- 2.2 右列表: 电视,空调... -->
|
<!-- 2.2 右列表: 电视,空调... -->
|
||||||
<view class="category_list">
|
<scroll-view class="category_list" scroll-y :scroll-top="scrollTop">
|
||||||
<view class="category_group" v-for="item in goods" :key="item.cat_name">
|
<view class="category_group" v-for="item in goods" :key="item.cat_name">
|
||||||
<!-- 2.2.1 标题 -->
|
<!-- 2.2.1 标题 -->
|
||||||
<view class="category_group_title">{{item.cat_name}}</view>
|
<view class="category_group_title">{{item.cat_name}}</view>
|
||||||
@ -24,7 +24,7 @@
|
|||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</scroll-view>
|
||||||
</view>
|
</view>
|
||||||
</view>
|
</view>
|
||||||
</template>
|
</template>
|
||||||
@ -41,6 +41,8 @@ export default {
|
|||||||
menuCurrent: 0,
|
menuCurrent: 0,
|
||||||
// 右列表
|
// 右列表
|
||||||
goods: [],
|
goods: [],
|
||||||
|
// 滚动到顶部
|
||||||
|
scrollTop: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
onLoad(){
|
onLoad(){
|
||||||
@ -60,10 +62,14 @@ export default {
|
|||||||
this.goods = message[this.menuCurrent].children
|
this.goods = message[this.menuCurrent].children
|
||||||
// console.log(this.goods);
|
// console.log(this.goods);
|
||||||
},
|
},
|
||||||
|
// 点击左菜单
|
||||||
onMenuTap(menuCurrent) {
|
onMenuTap(menuCurrent) {
|
||||||
this.menuCurrent = menuCurrent
|
this.menuCurrent = menuCurrent
|
||||||
this.goods = categoryData[menuCurrent].children
|
this.goods = categoryData[menuCurrent].children
|
||||||
|
// 一直为0没变化, 小程序不会发现
|
||||||
|
this.scrollTop = Math.random() / 1000;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user