This repository has been archived by the owner on Dec 6, 2021. It is now read-only.
Action-Sheet 展示页面出现关于 default slot 的警告 #3
Comments
ElTable 的子节点也需要传入函数式插槽,直接传数组是会报警告信息的。 createVNode(ElTable, {}, { default: () => [
createVNode(ElTableColumn, {}),
...
]}) |
谢谢! |
我今天看到你的问题 解决了 我也遇到了 报了警告 Non-function value encountered for default slot. Prefer function slots for better performance |
[Vue warn]: Slot "columns" invoked outside of the render function: this will not track dependencies used in the slot. Invoke the slot function inside the render function instead. v-slots={{ columns: () => slots.tableColumns() }} |
@Minitiai // 在 setup 中返回 render 函数
setup(props, { slots }) {
...
return () => {
return (/* jsx 代码 */)
}
}
// 或直接使用 render
render() {
return (/* jsx 代码 */)
} |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
开发工具所报的警告信息如下:
原因是组件插槽所插入的是插槽内容,而非函数值。Vue3 推荐使用函数式插槽,以便获得更佳的性能。
正确的写法如下:
The text was updated successfully, but these errors were encountered: