- 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.
25 lines
735 B
Markdown
25 lines
735 B
Markdown
# 练习 11:before 系列生命周期和 expose
|
||
|
||
## 目标
|
||
|
||
学会在组合式 API 中使用 before 系列生命周期,并理解子组件如何有选择地暴露能力给父组件。
|
||
|
||
## 你要练什么
|
||
|
||
- `onBeforeMount`
|
||
- `onBeforeUpdate`
|
||
- `onBeforeUnmount`
|
||
- `expose`
|
||
|
||
## 任务
|
||
|
||
- 在不同生命周期里输出日志
|
||
- 父组件通过模板 `ref` 获取子组件实例
|
||
- 子组件通过 `expose` 暴露一个 `focusInput` 方法
|
||
- 父组件点击按钮后调用这个暴露出来的方法
|
||
|
||
## 文件
|
||
|
||
- [starter.html](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/11-before-hooks-and-expose/starter.html)
|
||
- [starter.js](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/11-before-hooks-and-expose/starter.js)
|