使用 slot 的问题

在uni-app中:
自定义组件 scroll-list
<template>    <view v-for="(item, index) in dataList.rows" :key="index">
        <slot name="item" :item="item"></slot>
    </view>
</template>
使用组件
<scroll-list :dataList="dataList" :actionOptions="options">  <template #item="{item}">
    <view class="item" @click="toDetail(item.id)">
    </view>
  </template>
</scroll-list>
提示:slot "item" duplication is found under a single shadow root. The first one was accepted
怎么处理?
回答:
#item="{item}"改成#item="item"
回答:
外面再套一层
<template>    <view>
        <view v-for="(item, index) in dataList.rows" :key="index">
            <slot name="item" :item="item"></slot>
        </view>
    </view>
</template>
你这样封装有点奇怪,为什么不把slot中的内容一起封装到scroll-list里面呢?
回答:
你好 请问下有无找到问题所在?我也遇到一样的问题,找了好久没有方案处理
以上是 使用 slot 的问题 的全部内容, 来源链接: utcz.com/p/936139.html

