三里清风
三里清风
  • 发布:2023-09-06 10:41
  • 更新:2025-04-28 19:31
  • 阅读:535

微信小程序中 $slots 无法获取到节点内容

分类:uni-app

微信小程序 在组件中希望通过$slots / $scopedSlots ,获取到自定义的插槽内容。但是获取结果都是true。

// 组件内部 parentComponent  
<template>  
 <view>  
<slot row="1">默认内容</slot>  
</view>  

mounted(){  
console.log(this.$slots.default) // 输出 true  
console.log(this.$scopedSlots) // 输出 undefined  
}  

</template>  

// 外部调用 childrenComponent  
<parentComponent>  
<template v-slot="slotProps"></template>  
</parentComponent>  

PS:这个编辑器真难用

2023-09-06 10:41 负责人:无 分享
已邀请:
1***@qq.com

1***@qq.com

你好,有解决吗

DCloud_UNI_JBB

DCloud_UNI_JBB

小程序端为了性能考虑,没有 vnode,故不支持操作$slots,仅支持判断该slot是否存在。

要回复问题请先登录注册