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

Open
qhl123456 opened this issue May 28, 2024 · 0 comments
Open

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

qhl123456 opened this issue May 28, 2024 · 0 comments
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
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

2 participants