vue3+ts+setup中定义组件

//属性
interface Props {
  icon: string;
}
const props = withDefaults(defineProps<Props>(), {
  icon: '',
});
//方法
const emit = defineEmits(['change']);
function change(){
  let val = 'test';
  //方法名,方法传参
  emit('change', val);
}

 

posted @ 2024-12-27 22:37  tros  阅读(20)  评论(0)    收藏  举报