讓瀏覽器先取得 Vue,再執行 createApp。
現在要做:請在 index.html 的「Vue CDN script」位置完成:加入 Vue 3 global CDN 並放在 main.js 前面
貼上位置:index.html:Vue CDN script 區塊,先保留同一檔案的其他內容。
<script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
<script src="main.js" defer></script>預期結果:Network 有 Vue CDN,main.js 不再出現 Vue is not defined。
驗收證據:Network CDN 狀態與 Console 的 Vue 物件。
卡住時先看這裡
常見錯誤:把 main.js 放在 CDN 前面。
第一個檢查:先看 Network 的 script 順序與狀態碼。