文章详情页
解决vue3 defineProps 引入定义的接口报错
浏览:67日期:2022-06-09 15:05:23
问题遇到的现象
在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 引入报错的资料请关注其它相关文章!
标签:
JavaScript
排行榜
