0

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')

1 Answer 1

2

Try to import like

import { LandingPage } './components/LandingPage.vue'

Or

make export default to LandingPage component.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.