vue+ts实战笔记

74 阅读1分钟

ts主要是校验,在开发时发现错误,即使发现,开始使用有点不习惯,但是使用习惯还是很香的

给父组件传值

defineEmits<{
//可以写多个,void表示无返回
  (e:'on-click',name:string):void
}>()

给子组件传值,带有默认值

const props = withDefaults(defineProps<{
  title:string,
  arr:number
}>(),{
  title:'666'
  arr:()=>[123]
})