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:
38
08-vue3/07-composable-and-async/starter.js
Normal file
38
08-vue3/07-composable-and-async/starter.js
Normal file
@@ -0,0 +1,38 @@
|
||||
const { createApp, ref, onMounted } = Vue;
|
||||
|
||||
function useCourses() {
|
||||
const courses = ref([]);
|
||||
const loading = ref(true);
|
||||
const error = ref("");
|
||||
|
||||
async function loadCourses() {
|
||||
// 任务:
|
||||
// 1. 模拟异步请求
|
||||
// 2. 成功时给 courses 赋值
|
||||
// 3. 失败时给 error 赋值
|
||||
// 4. 最后把 loading 设为 false
|
||||
}
|
||||
|
||||
return {
|
||||
courses,
|
||||
loading,
|
||||
error,
|
||||
loadCourses,
|
||||
};
|
||||
}
|
||||
|
||||
createApp({
|
||||
setup() {
|
||||
const { courses, loading, error, loadCourses } = useCourses();
|
||||
|
||||
onMounted(() => {
|
||||
// 任务:页面挂载后调用 loadCourses
|
||||
});
|
||||
|
||||
return {
|
||||
courses,
|
||||
loading,
|
||||
error,
|
||||
};
|
||||
},
|
||||
}).mount("#app");
|
||||
Reference in New Issue
Block a user