Blogger Information
Blog 65
fans 2
comment 0
visits 60172
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
学完前端,结局憋了一大招,经典VUE选项卡,简直太tm优秀了...
张福根一修品牌运营
Original
852 people have browsed it

vue路由案例

案例展示:

vue路由案例

案例源码:

  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <script src="./lib/vue.js"></script>
  7. <script src="./vue-router-dev/dist/vue-router.js"></script>
  8. <title>vue路由案例</title>
  9. <style>
  10. body {
  11. display: grid;
  12. width: 100%;
  13. }
  14. div {
  15. width: 35rem;
  16. background-color: #d3d7d4;
  17. padding: 1.2rem 0.5rem;
  18. margin: 1rem;
  19. border-radius: 1% 1% 0% 0%;
  20. }
  21. a {
  22. padding: 0.5em;
  23. text-align: left;
  24. text-decoration: none;
  25. color: #130c0e;
  26. }
  27. p {
  28. width: 35rem;
  29. background-color: #d3d7d4;
  30. border-top: 1px solid grey;
  31. height: 20rem;
  32. padding-top: 0.5rem;
  33. }
  34. a:hover {
  35. color: #4f5555;
  36. }
  37. </style>
  38. </head>
  39. <body>
  40. <div class="app">
  41. <!-- 1、创建路由 -->
  42. <router-link to="jffx">旧房翻新</router-link>
  43. <router-link to="jbzx">局部装修</router-link>
  44. <router-link to="qmfx">墙面翻新</router-link>
  45. <router-link to="fsbl">防水补漏</router-link>
  46. <router-link to="wxaz">维修安装</router-link>
  47. <!-- 2、渲染路由 -->
  48. <router-view></router-view>
  49. </div>
  50. <script>
  51. // 创建模板
  52. const jffx = {
  53. template:
  54. "<p>旧房翻新<ul><li>三室两厅装修</li><li>两室一厅装修</li><li>一室一厅装修</li></ul></p>",
  55. };
  56. const jbzx = {
  57. template:
  58. "<p>局部装修<ul><li>卫生间翻新装修</li><li>厨房翻新装修</li><li>阳台翻新翻新装修</li></ul></p>",
  59. };
  60. const qmfx = {
  61. template: "<p>墙面翻新</p>",
  62. };
  63. const fsbl = {
  64. template: "<p>防水补漏</p>",
  65. };
  66. const wxaz = {
  67. template: "<p>维修安装</p>",
  68. };
  69. // 3、注册路由
  70. const router = new VueRouter({
  71. // 配置路由
  72. routes: [
  73. { path: "/jffx", component: jffx },
  74. { path: "/jbzx", component: jbzx },
  75. { path: "/qmfx", component: qmfx },
  76. { path: "/fsbl", component: fsbl },
  77. { path: "/wxaz", component: wxaz },
  78. ],
  79. });
  80. const vm = new Vue({
  81. router: router,
  82. el: ".app",
  83. });
  84. </script>
  85. </body>
  86. </html>
Correcting teacher:天蓬老师天蓬老师

Correction status:qualified

Teacher's comments:其实就是套路,记住步骤就可以了
Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post