- Introduced Vue3 exercises covering composable API, reactivity, lifecycle hooks, and built-in components. - Added structured interview plan for frontend candidates focusing on HTML, CSS, JavaScript, TypeScript, and Vue. - Included starter files for each exercise and detailed README documentation for guidance.
671 B
671 B
练习 13:script setup、defineProps、defineEmits、defineExpose
目标
补上 Vue3 在工程化单文件组件里的核心宏语法。
你要练什么
<script setup>definePropsdefineEmitsdefineExpose
说明
这一题不是浏览器 CDN 练习,而是单文件组件语法练习,需要放在 Vite + Vue3 之类的工程里使用。
任务
- 给子组件定义
title和finished两个 props - 定义
toggle事件并在按钮点击时触发 - 暴露一个
focusAction方法给父组件调用