注意:该问题在 vue3.3 及以上版本中已经被修复,也就是说 vue3.3 及以上版本中的宏函数中可以直接使用外部导入的类型。
更新说明链接:https://github.com/vuejs/core/pull/8083
Vue3 官网链接:TypeScript 与组合式 API | 为组件的 props 标注类型
interface IProps {
name: {
type: String,
default: "zhangsan"
}
}
// IProps 只能在当前文件中定义,不支持从外部导入
const props = defineProps<IProps>()