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:
39
08-vue3/05-props-and-emits/starter.js
Normal file
39
08-vue3/05-props-and-emits/starter.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const { createApp } = Vue;
|
||||
|
||||
createApp({
|
||||
components: {
|
||||
CourseItem: {
|
||||
props: {
|
||||
course: {
|
||||
type: Object,
|
||||
required: true,
|
||||
},
|
||||
},
|
||||
emits: ["toggle"],
|
||||
template: `
|
||||
<article class="card">
|
||||
<h2>{{ course.title }}</h2>
|
||||
<p :class="{ done: course.finished }">
|
||||
{{ course.finished ? "已完成" : "学习中" }}
|
||||
</p>
|
||||
<button type="button" @click="$emit('toggle', course.id)">切换状态</button>
|
||||
</article>
|
||||
`,
|
||||
},
|
||||
},
|
||||
setup() {
|
||||
const courses = Vue.ref([
|
||||
{ id: 1, title: "组合式 API", finished: true },
|
||||
{ id: 2, title: "组件通信", finished: false },
|
||||
]);
|
||||
|
||||
function toggleCourse(courseId) {
|
||||
// 任务:根据 courseId 切换对应课程的 finished
|
||||
}
|
||||
|
||||
return {
|
||||
courses,
|
||||
toggleCourse,
|
||||
};
|
||||
},
|
||||
}).mount("#app");
|
||||
Reference in New Issue
Block a user