0
我使用的是laravel 5.3 + inbuild VueJs組件。如何導入laravel中的外部組件5.3 + VueJs路徑
現在我想使用路由,所以我使用下面的代碼不工作。
const NotFound = { template: '<p>Page not found</p>' }
const Page1 = { template: '<p>home page</p>' }
const Page2 = { template: '<p>about page</p>' }
const routes = {
'/': Page1,
'/page2': Page2
}
const app = new Vue({
el: '#app',
data: {
currentRoute: window.location.pathname
},
computed: {
ViewComponent() {
return routes[this.currentRoute] || NotFound
}
},
render (h) { return h(this.ViewComponent) }
});
如何代替Page1
導入Example.vue
我試圖require('./components/Example.vue')
但它不工作,請幫助。
當你嘗試'const Page1 = require('./ components/Example.vue')'時,出現什麼錯誤? – SimonDepelchin
沒有錯誤,因爲gulp沒有運行這個代碼 – Drone
如果它沒有運行,它會拋出一個錯誤,不是嗎? – SimonDepelchin