相关相关 issues :https://github.com/vuejs/vue/issues/12153
一、产生原因
要注意 vue 与 vue-template-compiler 版本一致,主要原因是 vue 中 renderSlot 方法 调整,在 v2.6.13 版本,renderSlot 第二个参数支持 函数类型,同时 vue-template-compiler 编译slot 返回一个函数,但是v2.6.12 版本,renderSlot 第二个参数只是VNode,同时 vue-template-compiler 编译slot 直接返回一个VNode。因此如果 vue-template-compiler 版本比vue 版本高,就会出现这种情况。
二、解决办法
将 vue
和 vue-template-compiler
的版本号调整到 2.6.12
,或者更低版本即可。
但注意二者版本号要统一
三、codesandbox 网页代码测试
https://codesandbox.io/s/amazing-easley-n35zm?file=/src/components/HelloWorld.vue