uniapp scroll-view滚动到指定描点
时间: 2023-08-21 16:05:40 浏览: 132
要在uniapp中使用scroll-view滚动到指定描点,你可以通过以下步骤实现:
1. 首先,在scroll-view组件中,设置`scroll-into-view`属性为你要滚动到的描点的id。这个id可以是你想要滚动到的任意元素的id。
2. 然后,在你的页面中,给你要滚动到的描点添加一个id属性,并确保这个id是唯一的。
3. 最后,在你的样式文件中,添加以下样式规则来自定义滚动条的样式:
```css
::v-deep ::-webkit-scrollbar {
/* 滚动条整体样式 */
display: block;
width: 10rpx !important;
height: 10rpx !important;
-webkit-appearance: auto !important;
background: transparent;
overflow: auto !important;
}
::v-deep ::-webkit-scrollbar-thumb {
/* 滚动条里面小方块 */
border-radius: 10rpx !important;
box-shadow: inset 0 0 5rpx rgba(0, 0, 0, 0.2) !important;
background-color: #E2E2E2 !important;
}
::v-deep ::-webkit-scrollbar-track {
/* 滚动条 */
border-radius: 10rpx !important;
box-shadow: inset 0 0 5rpx rgba(0, 0, 0, 0.2) !important;
background-color: #ededed !important;
}
```
这样,当你使用scroll-view组件并设置了`scroll-into-view`属性后,页面会自动滚动到指定的描点。同时,你也可以通过自定义样式来美化滚动条的外观。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [uniapp scroll-view滚动条不显示](https://blog.csdn.net/LJJONESEED/article/details/123986312)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [微信小程序-scroll-view滚动到指定位置(类似锚点)](https://download.csdn.net/download/weixin_38601878/16213063)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [uniapp scroll-view显示滚动条](https://blog.csdn.net/qq_37215621/article/details/132016858)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文