父组件
<template>
<view class="content">
<abc :list="slotList">
<template #slot1="{ slotData }">
<view>
slot1 ==== {{ slotData }}
</view>
</template>
<template #slot2>
<view>
slot2 ====
</view>
</template>
<template #slot3>
<view>
slot3 ====
</view>
</template>
</abc>
</view>
</template>
<script setup>
import {
ref
} from 'vue';
import abc from './abc.vue'
const slotList = ref([{
name: 'slot1'
},
{
name: 'slot2'
},
{
name: 'slot3'
}
])
</script>
<style>
</style>
子组件
<template>
<view>
<text>这是动态插槽的组件</text>
<template v-for="(item, index) in list" :key="index">
<view >
<slot :name="item.name" :slotData="item"></slot>
</view>
</template>
</view>
</template>
<script setup>
defineProps({
list: Array
})
</script>
<style>
</style>
- 发布:2024-03-25 21:29
- 更新:2024-03-25 21:29
- 阅读:48
产品分类: uniapp/小程序/微信
PC开发环境操作系统: Windows
PC开发环境操作系统版本号: 22H2
HBuilderX类型: 正式
HBuilderX版本号: 3.99
第三方开发者工具版本号: 1.06.2402040win32-x64
基础库版本号: 3.34
项目创建方式: HBuilderX
示例代码:
操作步骤:
HBuilderX创建vue3 的默认模板 或者 命令行创建的vue3模板, 都有一样的问题
HBuilderX创建vue3 的默认模板 或者 命令行创建的vue3模板, 都有一样的问题
预期结果:
动态插槽正常取值 正常显示
动态插槽正常取值 正常显示
实际结果:
取值时未正常显示插槽内容
取值时未正常显示插槽内容
bug描述:
使用HBuilderX创建的vue3 基础模板, 代码中slot2, slot3 都可正常显示, slot1 无法正常显示内容