直接上typescript代码:
interface MenuItem {
name?: string,
icon?: string,
action?: string
}
const emit = defineEmits([]);
const props = defineProps({
list: Array
});
想将 list 数组元素定义为MenuItem类型时,可使用:
const props = defineProps({
list: Array as PropType<MenuItem[]>
});
参考:https://cn.vuejs.org/api/utility-types.html