index.js 833 B

1234567891011121314151617181920212223242526272829
  1. import {createRouter,createWebHistory,createWebHashHistory} from 'vue-router';
  2. import Home from '../views/Home.vue';
  3. import List from '../views/List.vue';
  4. /**
  5. * hash history区别
  6. * 1.hash:路径中包含# #后的内容不会发送到服务器上
  7. * 属于浏览器端的行为 不需要服务器配置 路径不是很美观
  8. * 参数会携带在#后 参数不是很安全
  9. * 2.history 路径不包含# 需要后端进行匹配的路由
  10. * 需要服务器进行配置 路径较美观
  11. * 参数可以隐藏 较安全
  12. */
  13. const router = createRouter({
  14. // 指定当前路由的模式
  15. history:createWebHistory(),
  16. // 定义路由表
  17. routes:[
  18. {
  19. path: '/home',
  20. component: Home
  21. }, {
  22. path: '/list',
  23. component: List
  24. }
  25. ]
  26. })
  27. export default router;