1. defineProps 可以直接解构
const {count = 0, message = '你好'} = defineProps<{count?:number,message?:string}>()
2. useId 项目中生成唯一id,自增的
const id = useId()
3. useTemplateRef
为了解决ref获取dom时候名称的误解
const el = useTemplateRef<HTMLButtonElement>('buttonRef')
// const el = ref('buttonRef') 有点像响应式数据,为了区分 <button ref="buttonRef"></button>
4. onWatchCleanup
import { onWatchCleanup }from 'vue'
watch(count,(n,o,oncleanup)={
//听的逻辑
onWatchCleanup(()=>{ 下一次监听执行前执行,用于清理上次监听的副作用 })
oncleanup(()=>{ 和 onWatchCleanup 作用完全一样 })
})