首页 > 编程语言 >uniapp开发使用slot插槽时小程序编译报错:Errors compiling template:目前仅支持解构插槽 otherSlotProps,如 v-slot="{ user }&

uniapp开发使用slot插槽时小程序编译报错:Errors compiling template:目前仅支持解构插槽 otherSlotProps,如 v-slot="{ user }&

时间:2023-03-13 11:22:51浏览次数:46  
标签:slot 插槽 解构 报错 user otherSlotProps

1.子组件中 

        <view>
            <slot :user="user">{{user.lastName}}</slot>
        </view>

2.在父组件使用

<template v-slot:default="otherSlotProps">
                {{ otherSlotProps.user.firstName }}
            </template>
                    

此时在编译到微信小程序中报错

 

 而运行到其他环境下比如H5是没问题的

 

那么在微信小程序中要使用解构插槽方式实现:

<template v-slot:default="{user}">
                {{ user.firstName }}
            </template>

 

标签:slot,插槽,解构,报错,user,otherSlotProps
From: https://www.cnblogs.com/yusilu-2653144/p/17210685.html

相关文章