在index.html中以cdn方式引入js文件
<script src="https://unpkg.com/vue-router/dist/vue-router.js"></script>
在src资源文件夹下面,创建router目录,目录下创建index.js文件,对vue-router插件进行全局配置 ```javascript import index from ‘../components/index/Index’ import mine from ‘../components/mine/Mine’ import admin from ‘../components/admin/Admin’ import notFind from ‘../components/notFind/NotFind’
export default new VueRouter({ mode: ‘history’, routes:[ { path:’/‘, name:’index’, component:index }, { path:’/mine’, name:’mine’, component:mine }, { path:’/admin’, name:’admin’, component:admin }, { path:’*’, name:’notFind’, component:notFind } ] })
3. 在程序入口界面引入配置,使配置生效,将router对象放入vue对象中,方面以后使用。
```javascript
new Vue({
el: '#app',
router,
components: { App },
template: '<App/>'
})