帖子
帖子
用户
博客
课程
显示全部楼层
54
帖子
0
勋章
1407
Y币

[多端开发] swiper v-for改变数组问题

[复制链接]
发表于 2021-12-16 16:41:23
avm3.0 v-for实现的轮播图,改变循环数组,会有空的格子,自带的指示点数量也不对,之前记得改好了,最近又不行了。
<scroll-view class="main" scroll-y>
        <text class="title">通过v-for加载</text>
        <swiper class="swiper" circular="false" indicator-dots indicator-color="#ddd" indicator-active-color="#f0f">
            <swiper-item class="swiper-item" v-for="(_item,_index) in dataList">
                <text class="desc">{_item}</text>
            </swiper-item>
        </swiper>
        <text class="title" @click="changeList">改变数组</text>
</scroll-view>

methods:{
            onchange(e){
                this.data.current = e.detail.current;
            },
            changeList(){
                this.change = !this.change;
                if(this.change){
                    this.dataList = ['item1', 'item2']
                }else{
                    this.dataList = ['item1', 'item2', 'item3', 'item4']
                }
            }
        }




380
帖子
4
勋章
6
Y币
android 还是 iOS?

提供一页测试代码。
54
帖子
0
勋章
1407
Y币
android 和iOS都不行
<template>
    <scroll-view class="main" scroll-y>
        <text class="title">通过v-for加载</text>
        <swiper class="swiper" circular="false" indicator-dots indicator-color="#ddd" indicator-active-color="#f0f">
            <swiper-item class="swiper-item" v-for="(_item,_index) in dataList">
                <text class="desc">{_item}</text>
            </swiper-item>
        </swiper>
        <text class="title" @click="changeList">改变数组</text>
    </scroll-view>
</template>
<style>
.box{
    flex-direction: row;
    justify-content: space-between;
}
.box_item{
    width: 48%;
}
.box_item_img{
    width: 100%;
}
    .main {
        width: 100%;
        height: 100%;
    }
    .swiper {
        width: 100%;
        height: 200px;
        background-color: blue;
    }
    .swiper-item {
          justify-content: center;
    }
    .title {
        padding: 10px 0;
        font-size: 20px;
    }
    .desc {
        width: 100%;
        text-align: center;
    }
    .container {
        width: 100%;
        height: 200px;
    }
    .indicator {
        flex-direction: row;
        justify-content: center;
        position: absolute;
        width: 100%;
        height: 20px;
        bottom: 8px;
    }
    .indicator-item {
        width: 15px;
        height: 8px;
        margin: 3px;
    }
    .indicator-item-normal {
        background-color: #ddd;
    }
    .indicator-item-active {
        background-color: red;
    }
</style>
<script>
    export default {
        name: 'test',
        data(){
            return {
                info:"<p>第一行<p><p>第二行</p>",   
                dataList: ['item1', 'item2', 'item3', 'item4'],
                current: 0,
                change:false
            }
        },
        methods:{
            onchange(e){
                this.data.current = e.detail.current;
            },
            changeList(){
                this.change = !this.change;
                if(this.change){
                    this.dataList = ['item1', 'item2']
                }else{
                    this.dataList = ['item1', 'item2', 'item3', 'item4']
                }
            }
        }
    }
</script>
技术支持-F · 2021-12-16 17:51android 还是 iOS?

提供一页测试代码。
28
帖子
1
勋章
1万+
Y币
iOS 重新编译再试试。
54
帖子
0
勋章
1407
Y币
IOS可以了,安卓也希望尽快支持
技术咨询-Kenny · 2021-12-17 17:01iOS 重新编译再试试。
20
帖子
1
勋章
7573
Y币
该问题已修复,重新编译app或自定义loader试试看。
您需要登录后才可以回帖 登录

本版积分规则