1***@qq.com
1***@qq.com
  • 发布:2019-09-09 13:38
  • 更新:2019-10-16 17:23
  • 阅读:1695

swiper为什么设置100%没有高度,怎么调自适应?

分类:uni-app

swiper为什么设置100%没有高度,怎么调自适应?

2019-09-09 13:38 负责人:无 分享
已邀请:
酒菜儿

酒菜儿

亲测,可用

<template>  
    <view>  
        {{items[current].height}}  

        <swiper class="swiper" @change="change" :style="{height: items[current].height + 'px'}">  
            <swiper-item>  
                <view class="swiper-item">  
                    <view class="bgwhite mt16 p16" v-for="d in 4" :key="d">{{d}}</view>  
                </view>  
            </swiper-item>  
            <swiper-item>  
                <view class="swiper-item">  
                    <view class="bgwhite mt16 p16" v-for="d in 20" :key="d">{{d}}</view>  
                </view>  
            </swiper-item>  
            <swiper-item>  
                <view class="swiper-item">  
                    <view class="bgwhite mt16 p16" v-for="d in 10" :key="d">{{d}}</view>  
                </view>  
            </swiper-item>  
        </swiper>  

    </view>  
</template>  

<script>  
    export default {  
        data() {  
            return {  
                current: 0,  
                items: []  
            }  
        },  

        mounted() {  
            uni.createSelectorQuery().selectAll('.swiper-item').boundingClientRect(data => this.items = data).exec()  
        },  

        methods: {  
            change(e) {  
                this.current = e.detail.current  
            }  
        }  
    }  
</script>  

该问题目前已经被锁定, 无法添加新回复