01、index.ts路由代码如下:
//创建路由并暴露出去 import {createRouter, createWebHistory} from 'vue-router' import Home from '@/view/Home.vue' import About from '@/view/About.vue' import News from '@/view/News.vue' const router = createRouter({ history: createWebHistory(), routes: [ {path: '/home', component: Home}, {path: '/about', component: About}, {path: '/news', component: News}, ] }) export default router
02、效果如下
03、index.ts代码如下:
//创建路由并暴露出去 import {createRouter, createWebHashHistory} from 'vue-router' import Home from '@/view/Home.vue' import About from '@/view/About.vue' import News from '@/view/News.vue' const router = createRouter({ history: createWebHashHistory(), routes: [ {path: '/home', component: Home}, {path: '/about', component: About}, {path: '/news', component: News}, ] }) export default router
04、习惯如下:
标签:About,TypeScript,vue,Vue3,component,HashHistory,import,Home,path From: https://www.cnblogs.com/tianpan2019/p/18366316