Reputation: 57
my vue components are working fine, but when i want it with vue router it unable to find the component
Upvotes: 1
Views: 186
Reputation:
Try it with like below.
component: Vue.component("Home", require("./Myhome").default)
You don't need to import it with this way.
Hope it helps.
Upvotes: 1
Reputation: 1373
The problem is with this code
{path:'home,component:MyHome}
So the reason for the error is, there is no MyHome
variable holding any component right. You just register your component with Vue.Component
which directly register your component.
Solution
So now for solving this, As Johhn said, Import your component and store it in variable and then pass that variable to your route like below.
import MyHome from "./components/MyHome.vue"
{path:'home,component:MyHome}
Upvotes: 1