定义props
1 第一种
interface AddType {
dialogStudyVisible: boolean;
}
const props = defineProps<AddType>();
第二种
// const props = defineProps({
// dialogStudyVisible:{
// type:Boolean,
// default:false
// }
// })
第三种
// const props = withDefaults(
// defineProps<{
//finishHandle: () => void //可以接受父节点方法
// dialogStudyVisible?:boolean
updatedHandle: (data:any) => void;
// }>(),
// {
// dialogStudyVisible:false,
//finishHandle: () => {}
updateHandle: () => {}
// }
// )
//自己业务逻辑
if(1=== 1){
props.finishHandle();
props.updateHandle(val);
}
定义ref
import { CAStep } from "../types";
export enum CAStep { plan = 1, plan = 2, }
1定义枚举类型
const step = ref<CAStep>(CAStep.plan);
2 -1定义对象类型
const columns = ref<StudyPreviewList>([]);
import { StudyPreviewList } from "@/api/interface/studyPath/index";
export interface StudyPreview{
headInfo1:{
propertyId:string,
propertyValue:string
},
stage0:{
propertyId:string,
propertyValue:string
}
}
export interface StudyPreviewList {
StudyPreviewList: StudyPreview[];
}
2-2 定义对象类型
const pList = ref<{
id: string;
name: string;
owner: number;
}[]>([]);
const planForm = reactive<{
planId: string;
address: boolean;
list: string[];
}>({
planId: '',
address: false,
list: [],
});
reactive 和 ref 一样