Files
front-end-example/08-vue3/12-built-in-components/starter.html
charlie d0d8be443b 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.
2026-03-24 23:02:58 +08:00

48 lines
1.8 KiB
HTML

<!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>