vue3 setup 语法糖

vue3 setup 语法糖:withDefaults、defineProps、defineEmits
withDefaults:
● withDefaults 只能与基于类型的defineProps声明一起使用;

defineProps:
相当于 vue2的 props 
1. const props = withDefaults(defineProps<Props>(), {
2.    msg: 'hello',
3.    labels: () => ['one', 'two'],
4.    obj: () => { return {a:2} }
5. })

defineEmits:
相当于 vue2 的 emits

你可能感兴趣的:(Vue,vue)