美文网首页
uni-app 自定义组件具名slot加入内容后多一层view节

uni-app 自定义组件具名slot加入内容后多一层view节

作者: holidayPenguin | 来源:发表于2024-08-05 11:29 被阅读0次

在uni-app自定义组件中,使用具名slot时,如果节点不是scroll-view,就会多增加一次view节点,即使已经手动增加了,也会再增加异常,具体原因还不清楚。

情况1,直接使用组件

  <CommonPage>
    <template #content>
      <IndexRenovation/>
    </template>
  </CommonPage>
image.png

情况2,嵌套异常view

  <CommonPage>
    <template #content>
      <view class="index">
        <IndexRenovation/>
      </view>
    </template>
  </CommonPage>
image.png

情况3,使用scroll-view原生组件

  <CommonPage>
    <template #content>
      <scroll-view height="100%" scroll-y lower-threshold="300">        
        <IndexRenovation/>
      </scroll-view>
    </template>
  </CommonPage>
image.png

uni-app官网 (dcloud.net.cn) - 各家小程序实现机制不同-可能存在的平台兼容问题

全局配置 | uni-app官网 (dcloud.net.cn)

相关文章