- 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.
44 lines
1.6 KiB
HTML
44 lines
1.6 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>组件通信与综合练习</title>
|
|
<style>
|
|
body { margin: 0; padding: 32px; font-family: "PingFang SC", sans-serif; background: #f4f7fb; }
|
|
.wrap { max-width: 860px; margin: 0 auto; display: grid; gap: 16px; }
|
|
.toolbar, .card { padding: 20px; border-radius: 18px; background: #fff; border: 1px solid #d9e3f2; }
|
|
.list { display: grid; gap: 14px; }
|
|
button { padding: 10px 14px; border: 0; border-radius: 999px; background: #2d6cdf; color: #fff; cursor: pointer; }
|
|
input { width: 100%; padding: 12px; border-radius: 12px; border: 1px solid #cfd8e8; }
|
|
.done { color: #1f8f54; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<section id="app" class="wrap">
|
|
<article class="toolbar">
|
|
<h1>Vue2 综合练习</h1>
|
|
<input ref="keywordInput" v-model="keyword" type="text" placeholder="输入关键字过滤课程" />
|
|
<button type="button" @click="focusInput">聚焦输入框</button>
|
|
</article>
|
|
|
|
<section class="list">
|
|
<course-card
|
|
v-for="course in filteredCourses"
|
|
:key="course.id"
|
|
:course="course"
|
|
theme="accent"
|
|
@toggle="toggleCourse"
|
|
>
|
|
<template v-slot:action>
|
|
切换完成状态
|
|
</template>
|
|
</course-card>
|
|
</section>
|
|
</section>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
|
|
<script src="./answer.js"></script>
|
|
</body>
|
|
</html>
|