Files
front-end-example/07-vue2/03-v-model-and-form/starter.html
charlie 3435848495 feat: add Vue2 exercises for dynamic styles, lifecycle methods, component communication, and course management dashboard
- Implement dynamic styles and event handling in Vue2 with a card component.
- Create lifecycle methods exercise to simulate async data loading and instance destruction.
- Develop a component communication exercise with props, events, and slots.
- Build a comprehensive course management dashboard with filtering, statistics, and component interactions.
2026-03-23 10:09:29 +08:00

60 lines
2.3 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>v-model 和表单</title>
<style>
body { margin: 0; padding: 32px; font-family: "PingFang SC", sans-serif; background: #f7f9fc; }
.wrap { max-width: 760px; margin: 0 auto; display: grid; gap: 18px; }
.card { padding: 22px; border-radius: 18px; background: #fff; border: 1px solid #dde5f3; }
input, textarea, select { width: 100%; margin-top: 8px; padding: 12px; border-radius: 12px; border: 1px solid #cfd8ea; }
</style>
</head>
<body>
<section id="app" class="wrap">
<article class="card">
<label>
昵称
<input v-model="nickname" type="text" placeholder="请输入昵称" />
</label>
<label>
学习目标
<textarea v-model="goal" rows="4" placeholder="请输入学习目标"></textarea>
</label>
<label>
当前阶段
<select v-model="stage">
<option value="入门">入门</option>
<option value="进阶">进阶</option>
<option value="项目实战">项目实战</option>
</select>
</label>
<div style="margin-top: 16px;">
<p>偏好的学习节奏</p>
<label><input v-model="pace" type="radio" value="每天学习" /> 每天学习</label>
<label><input v-model="pace" type="radio" value="每周集中学习" /> 每周集中学习</label>
</div>
<div style="margin-top: 16px;">
<p>已掌握的基础能力</p>
<label><input v-model="skills" type="checkbox" value="HTML" /> HTML</label>
<label><input v-model="skills" type="checkbox" value="CSS" /> CSS</label>
<label><input v-model="skills" type="checkbox" value="JavaScript" /> JavaScript</label>
</div>
</article>
<article class="card">
<h2>实时预览</h2>
<p>昵称:{{ nickname }}</p>
<p>学习目标:{{ goal }}</p>
<p>当前阶段:{{ stage }}</p>
<p>学习节奏:{{ pace }}</p>
<p>已掌握:{{ skills.join("、") }}</p>
</article>
</section>
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script src="./starter.js"></script>
</body>
</html>