vue-element-admin配置小結(jié)
1. 項(xiàng)目初始化
git clone https://github.com/PanJiaChen/vue-element-admin cd vue-element-admin npm install npm run dev
2. 項(xiàng)目精簡(jiǎn)
刪除scr/views下的源碼, 保留:
- dashboard:首頁(yè)
- error-page:異常頁(yè)面
- login:登錄
- redirect:重定向
對(duì)src/router/index 進(jìn)行相應(yīng)修改
import Vue from 'vue' import Router from 'vue-router' Vue.use(Router) /* Layout */ import Layout from '@/layout' /** * Note: sub-menu only appear when route children.length >= 1 * Detail see: https://panjiachen.github.io/vue-element-admin-site/guide/essentials/router-and-nav.html * * hidden: true if set true, item will not show in the sidebar(default is false) * alwaysShow: true if set true, will always show the root menu * if not set alwaysShow, when item has more than one children route, * it will becomes nested mode, otherwise not show the root menu * redirect: noRedirect if set noRedirect will no redirect in the breadcrumb * name:'router-name' the name is used by <keep-alive> (must set!!!) * meta : { roles: ['admin','editor'] control the page roles (you can set multiple roles) title: 'title' the name show in sidebar and breadcrumb (recommend set) icon: 'svg-name' the icon show in the sidebar noCache: true if set true, the page will no be cached(default is false) affix: true if set true, the tag will affix in the tags-view breadcrumb: false if set false, the item will hidden in breadcrumb(default is true) activeMenu: '/example/list' if set path, the sidebar will highlight the path you set } */ /** * constantRoutes * a base page that does not have permission requirements * all roles can be accessed */ export const constantRoutes = [ { path: '/redirect', component: Layout, hidden: true, children: [ { path: '/redirect/:path(.*)', component: () => import('@/views/redirect/index') } ] }, { path: '/login', component: () => import('@/views/login/index'), hidden: true }, { path: '/auth-redirect', component: () => import('@/views/login/auth-redirect'), hidden: true }, { path: '/404', component: () => import('@/views/error-page/404'), hidden: true }, { path: '/401', component: () => import('@/views/error-page/401'), hidden: true }, { path: '/', component: Layout, redirect: '/dashboard', children: [ { path: 'dashboard', component: () => import('@/views/dashboard/index'), name: 'Dashboard', meta: { title: 'Dashboard', icon: 'dashboard', affix: true } } ] } ] /** * asyncRoutes * the routes that need to be dynamically loaded based on user roles */ export const asyncRoutes = [ // 404 page must be placed at the end !!! { path: '*', redirect: '/404', hidden: true } ] const createRouter = () => new Router({ // mode: 'history', // require service support scrollBehavior: () => ({ y: 0 }), routes: constantRoutes }) const router = createRouter() // Detail see: https://github.com/vuejs/vue-router/issues/1234#issuecomment-357941465 export function resetRouter() { const newRouter = createRouter() router.matcher = newRouter.matcher // reset router } export default router
刪除 src/router/modules 文件夾
刪除 src/vendor文件夾
3. 項(xiàng)目配置
進(jìn)入src目錄下的settings.js配置文件
module.exports = { title: 'Project Title', showSettings: true, tagsView: true, fixedHeader: false, sidebarLogo: false, errorLog: 'production' }
3.1 項(xiàng)目標(biāo)題
在src/settings.js 配置項(xiàng)目標(biāo)題
3.2 showSettings
showSettings用來(lái)設(shè)置是否顯示控制面板,設(shè)置為false則不顯示
3.3 tagsView
tagsView是我們打開(kāi)某個(gè)頁(yè)面是否有頁(yè)面標(biāo)簽
3.4 fixedHeader
fixedHeader是內(nèi)容頁(yè)面向下滑動(dòng)時(shí)頭部是否固定,false是不固定, true是固定
3.5 sidebarLogo
sidebarLogo控制菜單欄上方是否顯示圖標(biāo)
3.6 源碼調(diào)試
打開(kāi)vue.config.js文件
找到如下圖的位置
cheap-source-map調(diào)試模式?jīng)]有完全編譯展示我們的源代碼
我們改成source-map調(diào)試模式,這時(shí)候再來(lái)看Sources的App.vue文件,已經(jīng)和源代碼顯示的一樣,在這樣的環(huán)境下調(diào)試我們會(huì)更加方便
但是source-map有一個(gè)缺點(diǎn),每當(dāng)我們程序有改動(dòng)時(shí),也需要同步生成source-map文件,這樣會(huì)使我們構(gòu)建變慢,在實(shí)際開(kāi)發(fā)過(guò)程中推薦使用eval,以增加構(gòu)建速度 在需要調(diào)試的時(shí)候使用source-map
4. 項(xiàng)目結(jié)構(gòu)分析
- api :接口請(qǐng)求
- assets :一些靜態(tài)文件
- components : 封裝組件
- direcetive :自定義指令
- filters :過(guò)濾器
- icons :圖標(biāo)
- layout :全局框架組件(非常重要)
- router :路由
- store :配置vuex
- styles :全局樣式文件
- utils :工具類(lèi)
- views :頁(yè)面組件
- App.vue :父組件,其他的組件都是嵌套在App.vue里
- main.js :全局入口文件,將App.vue設(shè)置為全局父組件進(jìn)行渲染
- permissions.js :登錄的校驗(yàn)和登錄之后的路由跳轉(zhuǎn)
- setting.js :配置文件
到此這篇關(guān)于vue-element-admin配置小結(jié)的文章就介紹到這了,更多相關(guān)vue-element-admin配置內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
運(yùn)行npm?run?dev報(bào)錯(cuò)的原因及解決
剛剛創(chuàng)建好vue項(xiàng)目的時(shí)候,運(yùn)行 npm run dev 會(huì)報(bào)錯(cuò),下面這篇文章主要給大家介紹了關(guān)于運(yùn)行npm?run?dev報(bào)錯(cuò)的原因及解決方法,需要的朋友可以參考下2022-10-10vue+xlsx實(shí)現(xiàn)表格的導(dǎo)入導(dǎo)出功能
這篇文章主要介紹了vue+xlsx實(shí)現(xiàn)表格的導(dǎo)入導(dǎo)出功能,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友參考下吧2023-11-11vue+vue-fullpage實(shí)現(xiàn)整屏滾動(dòng)頁(yè)面的示例代碼(直播平臺(tái)源碼)
這篇文章主要介紹了vue+vue-fullpage實(shí)現(xiàn)整屏滾動(dòng)頁(yè)面,本文通過(guò)示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2022-06-06Vant的安裝和配合引入Vue.js項(xiàng)目里的方法步驟
這篇文章主要介紹了Vant的安裝和配合引入Vue.js項(xiàng)目里的方法步驟,小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧2018-12-12vue 實(shí)現(xiàn)邊輸入邊搜索功能的實(shí)例講解
今天小編就為大家分享一篇vue 實(shí)現(xiàn)邊輸入邊搜索功能的實(shí)例講解,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09一文了解vue-router之hash模式和history模式
這篇文章主要介紹了一文了解vue-router之hash模式和history模式,本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2019-05-05vue-cli監(jiān)聽(tīng)組件加載完成的方法
今天小編就為大家分享一篇vue-cli監(jiān)聽(tīng)組件加載完成的方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過(guò)來(lái)看看吧2018-09-09