Reputation: 2197
I have lots of Vue components. I want to set up routing for them from the main.js file. But I'm unable to import my component here as it is a javascript file. How can I import my Vue component(.vue) here?
import Vue from 'vue'
import App from './App.vue'
// Components importing
import LandingPage './components/LandingPage.vue'; // error occurs here
const routes = [
{ path: '/', component: LandingPage },
]
const router = new VueRouter({
routes // short for `routes: routes`
})
Vue.config.productionTip = false
new Vue({
render: h => h(App),
router
}).$mount('#app')
Upvotes: 0
Views: 1011
Reputation: 229
Try to import like
import { LandingPage } './components/LandingPage.vue'
Or
make export default to LandingPage
component.
Upvotes: 2