看板 Ajax 關於我們 聯絡資訊
想請問各位高手們 前端新手剛摸索Vue.js 剛建立好的Component要如何順利顯示在網頁上呢? 使用了webpack建立了專案 剛開始localhost開啟網頁還有Hello Vue 之後新增了component test.vue 開啟localhost一直是空白頁 新增的component一直無法顯示 即使我把test.vue刪除 讓檔案跟原本剛建立時一樣 連Hello Vue都無法再顯示了 但localhost又可以顯示index.html的內容 我google了半天,發現大家都可以順利顯示Component 也參考了相關路由設定 還是無法顯示我的Component 求解 感謝大家 ----- Sent from JPTT on my Asus ASUS_Z01RD. -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 27.246.195.108 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/Ajax/M.1561751715.A.07B.html
brianwu1201: 問問題不貼個 codepen或code 的內容,是要大家通靈 06/29 12:44
brianwu1201: 嗎 XD 抱歉,我補上範例 下面是欲放上的component test.vue <template> <div class="show">{{msg}}</div> </template> <script> export default { data() { return { msg: "Hello!" }; } }; </script> (省略css) index.js修改如下 import Vue from "vue"; import Router from "vue-router"; import HelloWorld from "@/components/HelloWorld"; import test from "@/components/test"; Vue.use(Router); export default new Router({ routes: [ { path: "/", name: "HelloWorld", component: HelloWorld }, { path: "/test", name: "/test", component: test } ] }); main.js沒有更動到 import Vue from "vue"; import App from "./App"; import router from "./router"; Vue.config.productionTip = false; /* eslint-disable no-new */ new Vue({ el: "#app", router, components: { App }, template: "<App/>" }); 是按照網路上的範例 以vue cli建立的 但還是無法顯示自己新建的Component>< 謝謝 06/29 12:44 ※ 編輯: Louisay11 (150.117.253.10 臺灣), 06/29/2019 14:38:57
Rinorune: 那app.js呢 或是設個publicPath 06/29 15:50
pkro12345: 你的test.vue沒有name 07/01 13:02