vue-router路由
1.安装vue-router
npm install vue-router --save
2.使用vue-router
import VueRouter from 'vue-router' import Vue from 'vue' // 1,通过Vue.use(插件) 安装插件 Vue.use(VueRouter) // 2.配置路由及组件映射关系 const routes = [{ path: '/home', component: () => import('../components/Home') }, { path: '/about', component: ()=>import('../components/About') }] // 3.创建VueRouter对象 const router = new VueRouter({ routes }) export default router
3.使用router-view及router-link
<div id="app"> <router-link to="/home">首页</router-link> <router-link to="/about">关于</router-link> <router-view></router-view> </div>
相关推荐
前端小白 2020-07-19
bowean 2020-07-05
82344699 2020-07-05
85423468 2020-06-26
80437700 2020-05-15
80437700 2020-05-11
85423468 2020-05-05
85394591 2020-05-31
87133050 2020-02-24
80324291 2020-02-22
85394591 2020-02-22
80324291 2020-01-04
87133050 2020-01-03
82344699 2019-12-15
80324291 2019-12-07
85423468 2020-07-19
ggkuroky 2020-06-17