您的位置:首頁技術文章
文章詳情頁

解決vue3 defineProps 引入定義的接口報錯

瀏覽:26日期: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
国产综合久久一区二区三区