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:
23
08-vue3/02-reactive-and-computed/README.md
Normal file
23
08-vue3/02-reactive-and-computed/README.md
Normal file
@@ -0,0 +1,23 @@
|
||||
# 练习 2:reactive 和 computed
|
||||
|
||||
## 目标
|
||||
|
||||
学会把一组相关数据放进 `reactive`,并用 `computed` 推导派生结果。
|
||||
|
||||
## 你要练什么
|
||||
|
||||
- `reactive`
|
||||
- `computed`
|
||||
- 响应式对象
|
||||
- 派生状态
|
||||
|
||||
## 任务
|
||||
|
||||
- 用 `reactive` 管理课程信息
|
||||
- 用 `computed` 计算进度文案
|
||||
- 点击按钮后让完成课时增加
|
||||
|
||||
## 文件
|
||||
|
||||
- [starter.html](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/02-reactive-and-computed/starter.html)
|
||||
- [starter.js](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/02-reactive-and-computed/starter.js)
|
||||
25
08-vue3/02-reactive-and-computed/starter.html
Normal file
25
08-vue3/02-reactive-and-computed/starter.html
Normal file
@@ -0,0 +1,25 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
||||
<title>reactive 和 computed</title>
|
||||
<style>
|
||||
body { margin: 0; padding: 32px; font-family: "PingFang SC", sans-serif; background: #f6f8fc; }
|
||||
.panel { max-width: 720px; margin: 0 auto; padding: 24px; border-radius: 18px; background: #fff; border: 1px solid #dbe4f1; }
|
||||
button { padding: 10px 16px; border: 0; border-radius: 999px; background: #1c2f52; color: #fff; cursor: pointer; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<section id="app" class="panel">
|
||||
<h1>{{ course.title }}</h1>
|
||||
<p>总课时:{{ course.totalLessons }}</p>
|
||||
<p>已完成:{{ course.finishedLessons }}</p>
|
||||
<p>{{ progressText }}</p>
|
||||
<button type="button" @click="finishOneLesson">完成一节</button>
|
||||
</section>
|
||||
|
||||
<script src="https://cdn.jsdelivr.net/npm/vue@3/dist/vue.global.js"></script>
|
||||
<script src="./starter.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
26
08-vue3/02-reactive-and-computed/starter.js
Normal file
26
08-vue3/02-reactive-and-computed/starter.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const { createApp, reactive, computed } = Vue;
|
||||
|
||||
createApp({
|
||||
setup() {
|
||||
const course = reactive({
|
||||
title: "Vue3 响应式基础",
|
||||
totalLessons: 10,
|
||||
finishedLessons: 3,
|
||||
});
|
||||
|
||||
const progressText = computed(() => {
|
||||
// 任务:返回类似 “当前已完成 3 / 10 节”
|
||||
return "";
|
||||
});
|
||||
|
||||
function finishOneLesson() {
|
||||
// 任务:在不超过总课时的前提下,finishedLessons 加 1
|
||||
}
|
||||
|
||||
return {
|
||||
course,
|
||||
progressText,
|
||||
finishOneLesson,
|
||||
};
|
||||
},
|
||||
}).mount("#app");
|
||||
Reference in New Issue
Block a user