开发调试报警
[Vue warn]: Non-function value encountered for default slot. Prefer function slots for better performance.
原因
声明函数式组件时插槽传值时使用了非函数类型的值
代码语言:javascript复制const component = (props: any) => {
return h(
MyComponent1,
props,
h(MyComponent2)
)
}
解决
改写成如下形式即可
代码语言:javascript复制const component = (props: any) => {
return h(
MyComponent1,
props,
() => h(MyComponent2)
)
}