【发布时间】:2020-09-06 00:55:04
【问题描述】:
我有这个模板:
<template>
<my-body-component inline-component>
<slot/>
</my-body-component>
</template>
并且我希望 my-body-component 成为一个内联组件,其中包含插槽中的任何内容,但是当我以这种方式渲染主体时:
const my-body-component= {
render(h) {
return this.$slots.default;
}
};
我似乎无法访问 this.$slots.default。 在我自己的内联组件中获取插槽内容的好方法是什么?
我还得到:“'render' 隐式具有返回类型'any',因为它没有返回类型注释,并且在其返回表达式之一中直接或间接引用。”这个错误。
【问题讨论】:
标签: typescript vue.js