Open zhuanghaixin opened 3 years ago
-左右菜单要设置固定高度
监听scroll事件,判断当前滚动的距离是不是在右侧两个节点的区间之内,如果是的话,就让左侧菜单的当前索引等于对应数组索引
<template> <view class="category"> <SearchLink></SearchLink> <view class="content"> <scroll-view :scroll-y="true" class="left"> <view class="left-category" v-for="(item,index) in level1Categories" :key="index" @click="clickItem(index)" :class="{active:currentIndex===index}"> {{item.cat_name}} </view> </scroll-view> <scroll-view :scroll-into-view="toPosition" :scroll-top="scrollTop" :scroll-with-animation="ture" @scrolltoupper="upper" @scrolltolower="lower" @scroll="scroll" :scroll-y="true" class="right"> <image class="top-img" src="../../static/titleImage.png" mode=""></image> <view class="goods" v-for="(item,index) in level1Categories" :key="index" :id="'position'+index"> <block v-for="(secondItem,secondIndex) in item.children" :key="secondIndex"> <view class="title"> <text>/</text>{{secondItem.cat_name}}<text>/</text> </view> <view class="items"> <view class="item" v-for="(thirdItem,thirdIndex) in secondItem.children" :key="thirdIndex"> <image :lazy-load="true" mode="" :src="thirdItem.cat_icon"></image> <text>{{thirdItem.cat_name}}</text> </view> </view> </block> </view> </scroll-view> <view @tap="goTop" class="iconfont right-back-top">  </view> </view> </view> </template>
## 滚动比较消耗,需要防抖函数处理 ## 项目难点 ## [参考资料scroll-view](https://uniapp.dcloud.io/component/scroll-view?id=scroll-view) ## [参考资料createselectorquery](https://uniapp.dcloud.io/api/ui/nodes-info?id=createselectorquery)
历害!
点击左边的按钮时,右边可以跳动到指定的位置
-左右菜单要设置固定高度
滚动右边,左边菜单跳到相应的位置
监听scroll事件,判断当前滚动的距离是不是在右侧两个节点的区间之内,如果是的话,就让左侧菜单的当前索引等于对应数组索引