使用setup语法糖代替setup函数的时候使用了defineProps,然而在定义类型的时候一旦将接口暴露出去引用就发生了报错
import { IFromConfig } from "./search-input-config";
// import { defineProps } from "vue";
// interface IForm {
// label: string;
// value?: string;
// type?: string;
// options?: any;
// otherOptions?: any;
// }
// interface IFromConfig {
// formItem?: IForm[];
// }
const props = withDefaults(defineProps<IFromConfig>(), {
formItem: () => [{ label: "测试数据", value: "测试数据", type: "input" }],
});
[@vue/compiler-sfc] type argument passed to defineProps() must be a literal type, or a reference to an interface or literal type
在组件中直接定义接口就不会报错,
将接口封出去进行引用