feat: Add Vue3 exercises and interview plan

- 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.
This commit is contained in:
charlie
2026-03-24 23:02:58 +08:00
parent 3435848495
commit d0d8be443b
41 changed files with 1551 additions and 5 deletions

View File

@@ -0,0 +1,24 @@
# 练习 9toRef、toRefs 和 readonly
## 目标
学会把响应式对象里的字段拆出来继续保持响应式,并理解只读数据的使用场景。
## 你要练什么
- `toRef`
- `toRefs`
- `readonly`
## 任务
-`reactive` 管理学习者信息
-`toRef` 单独取出 `name`
-`toRefs` 拆出其余字段
-`readonly` 包一层设置项
- 点击按钮更新学习者信息并观察页面变化
## 文件
- [starter.html](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/09-reactivity-helpers/starter.html)
- [starter.js](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/09-reactivity-helpers/starter.js)

View File

@@ -0,0 +1,26 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>toRef、toRefs 和 readonly</title>
<style>
body { margin: 0; padding: 32px; font-family: "PingFang SC", sans-serif; background: #f5f8fc; }
.panel { max-width: 760px; margin: 0 auto; padding: 24px; border-radius: 18px; background: #fff; border: 1px solid #dbe4f2; }
button { padding: 10px 16px; border: 0; border-radius: 999px; background: #2d6cdf; color: #fff; cursor: pointer; }
code { background: #f2f6fb; padding: 2px 6px; border-radius: 8px; }
</style>
</head>
<body>
<section id="app" class="panel">
<h1>{{ name }}</h1>
<p>当前阶段:{{ stage }}</p>
<p>学习天数:{{ studyDays }}</p>
<p>主题模式:<code>{{ settings.theme }}</code></p>
<button type="button" @click="updateProfile">更新资料</button>
</section>
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js"></script>
<script src="./starter.js"></script>
</body>
</html>

View File

@@ -0,0 +1,33 @@
const { createApp, reactive, toRef, toRefs, readonly } = Vue;
createApp({
setup() {
const profile = reactive({
name: "林晨",
stage: "Vue3 入门",
studyDays: 12,
});
const name = toRef(profile, "name");
const { stage, studyDays } = toRefs(profile);
const settings = readonly({
theme: "light",
});
function updateProfile() {
// 任务:
// 1. 更新 name.value
// 2. 更新 stage.value
// 3. 让 studyDays.value + 1
// 4. 不要直接修改 settings.theme
}
return {
name,
stage,
studyDays,
settings,
updateProfile,
};
},
}).mount("#app");