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,22 @@
# 练习 12Teleport、Suspense 和 Transition
## 目标
认识 Vue3 常见内置组件在实际页面里的使用方式。
## 你要练什么
- `Teleport`
- `Suspense`
- `Transition`
## 任务
-`Teleport` 把弹层渲染到 `body`
-`Transition` 给弹层或提示做显隐动画
-`Suspense` 包裹一个异步组件,并显示 fallback
## 文件
- [starter.html](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/12-built-in-components/starter.html)
- [starter.js](/Users/lijiaqing/home/wwwroot/front-end-example/08-vue3/12-built-in-components/starter.js)

View File

@@ -0,0 +1,47 @@
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Teleport、Suspense 和 Transition</title>
<style>
body { margin: 0; padding: 32px; font-family: "PingFang SC", sans-serif; background: #f4f7fb; }
.panel { max-width: 760px; margin: 0 auto; padding: 24px; border-radius: 18px; background: #fff; border: 1px solid #d9e4f1; }
.modal { position: fixed; inset: 0; display: grid; place-items: center; background: rgba(12, 17, 29, 0.45); }
.modal-card { width: min(420px, calc(100vw - 32px)); padding: 24px; border-radius: 18px; background: #fff; }
.fade-enter-active, .fade-leave-active { transition: opacity .24s ease; }
.fade-enter-from, .fade-leave-to { opacity: 0; }
button { padding: 10px 14px; border-radius: 12px; border: 0; background: #2d6cdf; color: #fff; cursor: pointer; }
</style>
</head>
<body>
<section id="app" class="panel">
<h1>内置组件练习</h1>
<button type="button" @click="showModal = !showModal">切换弹层</button>
<Suspense>
<template #default>
<async-info></async-info>
</template>
<template #fallback>
<p>异步组件加载中...</p>
</template>
</Suspense>
<Teleport to="body">
<Transition name="fade">
<div v-if="showModal" class="modal">
<div class="modal-card">
<h2>练习弹层</h2>
<p>这里应该通过 Teleport 渲染到 body。</p>
<button type="button" @click="showModal = false">关闭</button>
</div>
</div>
</Transition>
</Teleport>
</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,24 @@
const { createApp, ref } = Vue;
createApp({
components: {
AsyncInfo: {
async setup() {
// 任务:
// 1. 模拟等待
// 2. 返回需要在模板中展示的数据
return {};
},
template: `
<p>这里会展示异步组件内容。</p>
`,
},
},
setup() {
const showModal = ref(false);
return {
showModal,
};
},
}).mount("#app");