- 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.
28 lines
562 B
JavaScript
28 lines
562 B
JavaScript
const { createApp, provide, inject } = Vue;
|
|
|
|
createApp({
|
|
components: {
|
|
ThemeCard: {
|
|
setup() {
|
|
const themeColor = inject("themeColor");
|
|
|
|
return {
|
|
themeColor,
|
|
};
|
|
},
|
|
template: `
|
|
<article class="card">
|
|
<h2>主题卡片</h2>
|
|
<button type="button" :style="{ background: themeColor }">
|
|
<slot>默认按钮</slot>
|
|
</button>
|
|
</article>
|
|
`,
|
|
},
|
|
},
|
|
setup() {
|
|
// 任务:通过 provide 提供 themeColor
|
|
return {};
|
|
},
|
|
}).mount("#app");
|