- 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.
33 lines
1.2 KiB
HTML
33 lines
1.2 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: #f5f8fc; }
|
|
.panel { max-width: 760px; margin: 0 auto; padding: 24px; border-radius: 18px; background: #fff; border: 1px solid #dbe4f4; }
|
|
ul { padding-left: 18px; }
|
|
button { padding: 10px 16px; border: 0; border-radius: 999px; background: #2f6ee5; color: #fff; cursor: pointer; }
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<section id="app" class="panel">
|
|
<h1>Vue2 渲染练习</h1>
|
|
<button type="button" @click="showList = !showList">切换课程列表</button>
|
|
|
|
<p v-if="isPaid">你已经开通会员课程。</p>
|
|
<p v-else>你还没有开通会员课程。</p>
|
|
|
|
<ul v-show="showList">
|
|
<li v-for="course in courses" :key="course.id">
|
|
{{ course.title }} - {{ course.status }}
|
|
</li>
|
|
</ul>
|
|
</section>
|
|
|
|
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
|
|
<script src="./answer.js"></script>
|
|
</body>
|
|
</html>
|