在index.js文件把其他界面引入,
import home from 'components/home/home' import mine from 'components/mine/mine' import find from 'components/find/find'如果没有安装vue-router,要在cmd中 install
然后在index.js中引入
import Router from 'vue-router'
然后路由的命名
export default new Router({ mode: 'history', routes: [{ path: '/home', name: 'home', component: home },{ path: '/mine', name: 'mine', component: mine }, { path: '/find', name: 'find', component: find } ]})路由有两种模式:
vue-router
默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。如果不想要很丑的 hash,我们可以用路由的 history 模式,这种模式充分利用
history.pushState
API 来完成 URL 跳转而无须重新加载页面。
vue-router
默认 hash 模式 —— 使用 URL 的 hash 来模拟一个完整的 URL,于是当 URL 改变时,页面不会重新加载。如果不想要很丑的 hash,我们可以用路由的 history 模式,这种模式充分利用
,history.pushState
API 来完成 URL 跳转而无须重新加载页面。