问题遇到的现象
在setup语法糖使用了defineProps,然而在定义类型的时候一旦将接口暴露出去引用就发生了报错
问题相关代码
interface Props { /* ... */ } export { type Props }
<script setup lang="ts"> import { Props } from '.' const props = defineProps<Props>() </script>
运行结果及报错内容
[@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type.
我的解答思路和尝试过的方法
在组件中直接定义接口就不会报错,
我想要达到的结果
将接口封出去进行引用
以上就是解决vue3 defineProps 引入定义的接口报错的详细内容,更多关于vue3 defineProps 引入报错的资料请关注其它相关文章!
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)