简体   繁体   中英

Problem with defining templates in vue.js single page frontend app

I've got a problem with defining templates(home, partlists, schematichs) for may single page application. I tried to adds some imports but then it also throws error.

const routes=[
    {path:'/home',component:home},
    {path:'/partlist',component:partlists},
    {path:'/schematic',component:schematics}

]

const router= VueRouter.createRouter({
    history: VueRouter.createWebHashHistory(),
    routes,
})

const app = Vue.createApp({})
app.use(router)
app.mount('#app')

At least on this code, you didn't imported any component. Assuming your components are placed at 'components' folder, this should do:

import home from '@/components/home'
import partlists from '@/components/partlists'
import schematics from '@/components/schematics'

const routes=[
    {path:'/home',component:home},
    {path:'/partlist',component:partlists},
    {path:'/schematic',component:schematics}

]

const router= VueRouter.createRouter({
    history: VueRouter.createWebHashHistory(),
    routes,
})

const app = Vue.createApp({})
app.use(router)
app.mount('#app')

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM