<MyCustom :config="[{ name: 'input' }]">
<template v-slot:input="slotsProps">2212</template>
</MyCustom>
<view>
<template v-for="item in config">
<slot :name="item.name" xxx="测试文字"></slot>
</template>
</view> 产品分类: uniapp/小程序/微信
PC开发环境操作系统: Mac
PC开发环境操作系统版本号: 15.3.2
第三方开发者工具版本号: 1.06.2504010
基础库版本号: 3.0.0-alpha-4080420251023001
项目创建方式: CLI
CLI版本号: 3.0.0-alpha-4080420251023001
<MyCustom :config="[{ name: 'input' }]">
<template v-slot:input="slotsProps">2212</template>
</MyCustom>
<view>
<template v-for="item in config">
<slot :name="item.name" xxx="测试文字"></slot>
</template>
</view> 按照代码应该可以复现
正常渲染
不渲染 - 外层的slot名称似乎被更改了。并没有按照实际的
当正常使用自定义组件的slot插槽时 v-slot:xxx="slotsProps" ,slot绑定就会失败,子组件无法正常渲染。去除="slotsProps"后正常渲染。
查看dom节点发现添加了="slotsProps"时,他会自动为<view slot="xxx-0"/>添加 -index索引 导致匹配不上slot
1 个回复
DCloud_UNI_JBB
发个可复现demo