使用 <scroll-view>组件。设置scroll-into-view 的值为右侧标题的 id。点击左侧标题时 切换右侧标题 id (scroll-view | uni-app官网
上代码:
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41<!-- 左侧标题 --> <scroll-view scroll-y="true" style="width: 220rpx" > <view class="tags-sort-left"> <text v-for="(ft, index) in leftTitle" :key="index" @click="changeLeftTitle(index)" > {{ ft.title }} </text> </view> </scroll-view> <!-- 右侧内容 --> <scroll-view class="tags-sort-right" :scroll-into-view="scrollInto" // 子元素id scroll-y="true" scroll-with-animation="true" > <template v-for="(hotTag, index1) in hotTags" :key="index1" > <view :id="'item-' + index1" //这里要动态设置id class="tags-box" > ...布局 </view> </template> </scroll-view> // 点击左侧标题, const changeLeftTitle= (index: number) => { state.scrollInto = `item-${index}` //改变右侧id,使其滑动 }
最后
以上就是自信手套最近收集整理的关于uniapp点击侧边栏,对应数据滚动定位的全部内容,更多相关uniapp点击侧边栏内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复