国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

深入理解vue2.0路由如何配置問題

2024-05-06 15:14:15
字體:
來源:轉載
供稿:網(wǎng)友

這兩天學習了Vue.js 感覺路由這個地方知識點挺多的,而且很重要,所以,今天添加一點小筆記。

項目基本手腳架搭建完畢后,建一個router文件夾,里面配置一個index.js文件。

文件內(nèi)容:

npm install vue-router vue-resource --save-dev(安裝 vue 路由模塊vue-router和網(wǎng)絡請求模塊vue-resource)

import Vue from 'vue' import Router from 'vue-router' (----引入路由---注釋說明) import About from '@/components/about'(--這些需要引入的是components文件夾下面創(chuàng)建的一些模板---相對路徑----about代表about.vue模塊) import Home from '@/components/home' import Brand from '@/components/brand' import Company from '@/components/company' import Connect from '@/components/connect' import Main from '@/components/main' import Join from '@/components/join' import News from '@/components/news' import Products from '@/components/products' import son1 from '@/components/son1' import son2 from '@/components/son2' import list from '@/components/list' import newList from '@/components/newList' import culture from '@/components/culture' import certification from '@/components/certification' import zhuanjia from '@/components/zhuanjia' Vue.use(Router) (--使用---)  export default new Router({  routes: [   {    path: '/main',    name: 'main',    component: Main   },--------------------------------   { path: '/',           這里是路由重定向,比如頁面加載時候進入首頁    redirect: '/main'          (比如給路由一個選中后的樣式為紅色 那么這里就能用到了---.router-link-active{樣式})   },---------------------------------   {---------------------這里是配置子路由    path: '/brand',    name: 'brand',    component: Brand,    children: [     {      path: '/',      name: 'newList',      component: newList     },     {      path: '/brand/culture',      name: 'culture',      component: culture     },     {      path: '/brand/certification',      name: 'certification',      component: certification     },     {      path: '/brand/zhuanjia',      name: 'zhuanjia',      component: zhuanjia     }    ]   },   {    path: '/about',    name: 'about',    component: About   },   {    path: '/company',    name: 'company',    component: Company   },   {    path: '/connect',    name: 'connect',    component: Connect   },   {    path: '/home',    name: 'home',    component: Home   },   {    path: '/join',    name: 'join',    component: Join,    children: [     {      path: '/',      name: 'son1',      component: son1     },     {      path: '/join/son2',      name: 'son2',      component: son2     }    ]   },   {    path: '/list',    name: 'list',    component: list   },   {    path: '/news',    name: 'news',    component: News   },   {    path: '/products',    name: 'products',    component: Products   }  ] }) 

接下來就是在每一個模塊文件中加入這樣的一句話暴露出去:

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 高邮市| 金坛市| 法库县| 晋宁县| 论坛| 镇坪县| 漯河市| 濉溪县| 巴南区| 龙岩市| 漳平市| 合山市| 金山区| 二连浩特市| 大渡口区| 鹤岗市| 如皋市| 游戏| 双流县| 酒泉市| 伊通| 海晏县| 徐州市| 上林县| 温州市| 尼勒克县| 金沙县| 庆阳市| 泸州市| 河津市| 和静县| 宜阳县| 财经| 贺兰县| 丁青县| 容城县| 大宁县| 澎湖县| 河南省| 晋中市| 徐闻县|