先把一張卡片的畫面責任封裝起來,讓父層只負責資料清單。
現在要做:先對照差異,再檢查 在 main.js 的「ServiceCard 宣告(createApp 之前)」對照這項變更:const ServiceCard = {
props: {
service: { type: Object, required: true },
},
template: <article class="service-card">
<h2>{{ service.name }}</h2>
<p>{{ service.summary }}</p>
</article>,
};
貼上位置:main.js 的 ServiceCard 宣告(createApp 之前) 區塊
const ServiceCard = {
props: {
service: { type: Object, required: true },
},
template: `<article class="service-card">
<h2>{{ service.name }}</h2>
<p>{{ service.summary }}</p>
</article>`,
};預期結果:元件在 app.component 註冊後可以接收父層傳入的 service,並顯示 name 與 summary。
驗收證據:main.js 的元件宣告位於 createApp 外;畫面出現兩張卡片且文字來自 props。
卡住時先看這裡
常見錯誤:只複製完整答案,卻沒有先理解這一項差異的責任。
第一個檢查:只對照目前差異指定的檔案與 anchor。