1.首先下载vue-router yarn add vue-router@next
2.创建文件router/index.js
```
import { createRouter, createWebHashHistory } from "vue-router";
const routes = [
{
path:"/",
name:"home",
component:()=>import("@/components/home.vue")
}
]
const router = createRouter({
history: createWebHashHistory(),
routes
});
export default router;
```
3.在main.js引入router,挂载router
4.在app.vue中放入路由
git克隆地址 https://github.com/GitfishHub/vue.3.0easyencapsulation.git