uni-app scroll-view左右滾動


要點: 

使用豎向滾動時,需要給 <scroll-view> 一個固定高度,通過 css 設置 height。

使用橫向滾動時,需要給 <scroll-view> 一個固定寬度,通過 css 設置 width。

<template>
    <view class="tab">
        <scroll-view class="tab-scroll-view" :scroll-x="true">
            <view class="tab-item" v-for="(item, index) in tabList" :key="index">
                 {{item.name}}
            </view>
        </scroll-view>
    </view>
</template>
<style lang="less">
    .tab-scroll-view {
        width: 750rpx;
        height: 84rpx;
        flex-direction: row;
        white-space: nowrap;
        .tab-item {
            display: inline-block;
            width: 150rpx;
            height: 284rpx;
            font-size: 16px;
            color: #555;
            border: 1px solid yellow;
        }
    }
</style>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM