scroll-view scroll-y
时间: 2023-10-08 19:12:30 浏览: 187
scroll-view组件中的属性scroll-y是用来开启纵向滚动功能的。当将scroll-y设定为true时,scroll-view组件就可以在纵向上滚动。要开启纵向滚动功能,需要给scroll-view设置一个高度,并且内容的高度要大于scroll-view的高度才能体现出滚动功能。如果内容的高度小于scroll-view的高度,就无法滚动。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [uniapp scroll-view基础用法](https://blog.csdn.net/lxgyydsgod/article/details/126212359)[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: 100%"]
[ .reference_list ]
相关问题
<scroll-view scroll-y="true" scroll-into-view="{{s}}" style="height: {{scrollViewHeight}}px;" scroll-with-animation="true"> scroll-into-view 绑定没有效果
你好!对于你提到的 scroll-into-view 绑定没有效果的问题,可能有几个原因导致。
首先,请确保你的代码中的 scroll-view 组件已经正确引入,并且在视图中正确地显示出来。
其次,检查一下你设置的 scroll-into-view 值是否正确。scroll-into-view 属性需要绑定一个在 scroll-view 内部的子元素的 id 或选择器。确保你绑定的是一个存在的元素,并且它在 scroll-view 中可见。
此外,你还可以尝试给 scroll-view 组件添加一个唯一的 id 属性,并将 scroll-into-view 绑定到这个 id。例如:
```html
<scroll-view id="my-scroll-view" scroll-y="true" scroll-into-view="{{s}}" style="height: {{scrollViewHeight}}px;" scroll-with-animation="true">
<!-- 内容 -->
</scroll-view>
```
然后,在你的逻辑中,确保变量 s 的值和你想要滚动到的元素的 id 或选择器匹配。
最后,如果以上步骤都没有解决问题,可能是由于其他代码或样式的冲突导致。你可以尝试简化代码,逐步排查可能引起问题的部分。
希望这些提示能帮到你!如果有任何进一步的问题,请随时提问。
<scroll-view class="scroll-wrapper" scroll-x scroll-with-animation="true" scroll-into-view="item{{currentTab < 4 ? 0 : currentTab - 3}}"> <view class="navigate-item" id="item{{index}}" wx:for="{{tabList}}" wx:key="index" data-index="{{index}}" bindtap="tabNav"> <view class="names {{currentTab === index ? 'active' : ''}}">{{item.name}}</view> <view class="currtline {{currentTab === index ? 'active' : ''}}" wx:if="{{currentTab === index}}"></view> </view> </scroll-view> <swiper indicator-dots="{{false}}" bindchange="handleSwiper" current="{{currentTab}}"> <block wx:for="{{tabList}}" wx:key="index"> <swiper-item style="overflow: scroll;"> <view class="tab_title">tab{{currentTab+1}}内容</view> <scroll-view scroll-y refresher-enabled refresher-background="#F6F7F8" refresher-triggered="{{isRefresh}}" bindrefresherrefresh="refresherpulling" bindscrolltolower="handleTolower"> <view class="swiper-item" wx:for="{{20}}" wx:key="index">第{{index + 1}}条数据~</view> </scroll-view> </swiper-item> </block> </swiper> 将这段微信小程序代码转化成vue框架下的代码
<template>
<div>
<scroll-view class="scroll-wrapper" scroll-x scroll-with-animation="true" :scroll-into-view="`item${currentTab < 4 ? 0 : currentTab - 3}`">
<view class="navigate-item" :id="`item${index}`" v-for="(item, index) in tabList" :key="index" :data-index="index" @tap="tabNav">
<view class="names" :class="{ active: currentTab === index }">{{item.name}}</view>
<view class="currtline" :class="{ active: currentTab === index }" v-if="currentTab === index"></view>
</view>
</scroll-view>
<swiper :indicator-dots="false" @change="handleSwiper" :current="currentTab">
<swiper-item v-for="(item, index) in tabList" :key="index" style="overflow: scroll;">
<view class="tab_title">tab{{currentTab+1}}内容</view>
<scroll-view scroll-y refresher-enabled refresher-background="#F6F7F8" :refresher-triggered="isRefresh" @refresherrefresh="refresherpulling" @scrolltolower="handleTolower">
<view class="swiper-item" v-for="(item, index) in 20" :key="index">第{{index + 1}}条数据~</view>
</scroll-view>
</swiper-item>
</swiper>
</div>
</template>
<script>
export default {
data() {
return {
currentTab: 0,
isRefresh: false,
tabList: [{ name: 'tab1' }, { name: 'tab2' }, { name: 'tab3' }, { name: 'tab4' }, { name: 'tab5' }]
}
},
methods: {
tabNav(e) {
this.currentTab = e.currentTarget.dataset.index
},
handleSwiper(e) {
this.currentTab = e.detail.current
},
refresherpulling() {
// 下拉刷新
},
handleTolower() {
// 上拉加载更多
}
}
}
</script>
阅读全文
相关推荐













