retrocode
retrocode
  • 发布:2019-05-29 09:12
  • 更新:2022-01-29 09:30
  • 阅读:1834

【报Bug】自定义组件模式 swiper中无法使用slot

分类:uni-app

详细问题描述

我封装了一个swiper组件,通过slot传入数据显示相关页面,当slot是swiper-item时,在H5端正常显示,单小程序及APP端无法显示swiper-item信息,
暂时确认是slot的问题,我在组件内直接使用swiper-item是没有任何问题的

[内容]

重现步骤

[步骤]

<!-- 主页 -->    
<template>    
    <!-- 主页开始 -->    
    <test-components :tabBars="tabBars">    
        <template v-slot:swiperpage>    
            <swiper-item><view class="swiper-page">问君能有几多愁</view></swiper-item>    
            <swiper-item><view class="swiper-page">恰似一江春水向东流</view></swiper-item>    
        </template>    
        <template v-slot:footer>    
            这里是底部    
        </template>    
    </test-components>    
    <!-- 主页结束 -->    
</template>  
<template>    
    <view class="container">    
        <header>    
            <!-- tab栏 -->    
            <scroll-view id="tab-bar" class="header-center uni-swiper-tab" scroll-x :scroll-left="scrollLeft">    
                <view    
                    v-for="(tab, index) in tabBars"    
                    :key="tab.id"    
                    :class="['swiper-tab-list', tabIndex == index && tabBars.length > 1 ? 'active' : '']"    
                    :id="tab.id"    
                    :data-current="index"    
                    @click="tapTab(index)"    
                >    
                    {{ tab.name }}    
                </view>    
            </scroll-view>    
        </header>    
        <view class="uni-tab-bar">    
            <!-- 下拉刷新组件 -->    
            <!-- :top="90" -->    
            <pulldown-refresh ref="mixPulldownRefresh"  @refresh="onPulldownReresh" @setEnableScroll="setEnableScroll">    
                <!-- swiperpage组件开始 -->    
                <swiper @change="changeTab" :current="tabIndex" class="swiper-box" duration="300" skip-hidden-item-layout="true">    
                    <!-- swiperpage开始 -->    
                    <slot name="swiperpage"></slot>    
                    <!-- swiperpage结束 -->    
                </swiper>    
                <!-- swiperpage组件结束 -->    
            </pulldown-refresh>    
            <!-- 下拉刷新组件结束 -->    
        </view>    
        <footer><slot name="footer"></slot></footer>    
    </view>    
</template>  

[结果]

[期望]
APP端及小程序端应与H5端显示一致才对

uni-app运行环境说明

[运行端是h5或app或某个小程序?] APP/H5/小程序

[编译模式是老模板模式还是新的自定义组件模式?] 自定义组件模式

2019-05-29 09:12 负责人:无 分享
已邀请:
DCloud_UNI_HT

DCloud_UNI_HT

bug确认,已加分

  • retrocode (作者)

    这个BUG短期内会修复吗?如果可以我就先按H5开发了,不行的话我就要考虑规避掉这个BUG了


    2019-05-29 18:29

  • DCloud_UNI_HT

    回复 retrocode: 微信原因,暂时修复不了


    2019-06-10 13:34

  • 1***@163.com

    回复 DCloud_UNI_HT: 修复好了吗?这个问题修复好至少可以省三分之一代码量


    2021-05-06 15:26

  • DCloud_UNI_HT

    回复 1***@163.com: 因为小程序组件,会默认在外层多一层节点 ,而swipe 和 swipe-item 中间又不能有其他节点 ,就导致这个问题的出现了。现在还不太好解决 ,只能等微信修复了


    2021-06-15 11:03

2***@qq.com

2***@qq.com

我还以为一直是我写的代码问题,原来是个BUG

hello2

hello2

我H5也不正常

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