引入
1、配置路由器规则
const routes =[
{path:"/home", component: HomePage},
{path:"/about", component: AboutPage},
{path:"/news"", component: NewsPage,name: 'news'},
]
2、创建路由器
const router = createRouter({
history:createWebHistory(), //路由工作模式
routes
})
3、加载路由器
const app = createApp(App)
app.use(router)
app.mount('#app')
4、在页面上的使用