Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

动态插槽拿不到作用域插槽的值 #4940

Closed
qhl123456 opened this issue May 28, 2024 · 2 comments
Closed

动态插槽拿不到作用域插槽的值 #4940

qhl123456 opened this issue May 28, 2024 · 2 comments
Assignees
Labels

Comments

@qhl123456
Copy link

给了动态插槽后,同时还是作用域插槽,父组件拿不到作用域插槽的值

子组件代码:






        <slot v-if="item.isCustomContent" :name="item.slotName || 'record'" :item="item" :dataItem="dataItem" :index="index"></slot>
        <template v-else>
          <view class="card-list-item-title"> {{ item.title }} : </view>
          <view class="card-list-item-text">
            {{ dataItem[item.prop] === 0 ? "0" : dataItem[item.prop] || "-" }}
          </view>
        </template>
      </template>
    </view>
  </template>
</view>

父组件代码:

<template #distance="{ item }"> 123 --{{ item }}



const cardConfigHelp = reactive({
columns: [
{ title: "救援时间", prop: "time" },
{ title: "救援地点", prop: "address" },
{ title: "救援距离", prop: "distance", slotName: "distance", isCustomContent: true },
{ title: "救援费", prop: "money", isCustomContent: true }
],
isCustomTitle: true,
isCustomContent: false,
isCustomFooter: false
})

这样父组件拿作用域插槽的值直接不渲染插槽了,写死123可以显示

@qhl123456 qhl123456 changed the title 动态插槽问题 动态插槽拿不到作用域插槽的值 May 28, 2024
@GRCmade
Copy link
Collaborator

GRCmade commented Mar 17, 2025

hello , 你这个问题应该出现在小程序上吧,小程序上,不支持作用于插槽https://zh.uniapp.dcloud.io/tutorial/vue3-components.html#%E5%B0%8F%E7%A8%8B%E5%BA%8F%E4%B8%8D%E6%94%AF%E6%8C%81%E5%88%97%E8%A1%A8

@GRCmade GRCmade self-assigned this Mar 17, 2025
@GRCmade
Copy link
Collaborator

GRCmade commented Mar 24, 2025

长时间未回复,关闭 issue,如果还存在这个问题,可以重新打开

@GRCmade GRCmade closed this as completed Mar 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants