基于vue+springboot 搭建一套通用管理后台
主要包括用户管理模块、权限模块、菜单模块,
项目代码 https://gitee.com/weiwei20180921/commonadmin-front-a
PS D:\front> npm -v
8.5.0PS D:\front> npm config get 'registry'
https://registry.npm.taobao.org/
PS D:\front>
PS D:\front\commonadmin-front> vue -V
@vue/cli 5.0.8
PS D:\front\commonadmin-front>
PS D:\front\commonadmin-front> node -v
v16.14.2
PS D:\front\commonadmin-front>
使用vue cli 在你想要创建的目录创建项目
PS D:\front> vue create commonadmin-frontVue CLI v5.0.8
? Please pick a preset: Default ([Vue 2] babel, eslint)
在gitee 上新建项目,然后按着命令 push即可。
注意1. 要过滤掉node_modules 目录,该目录无需推送到gitee 上。
我是直接删除的。
PS D:\front\commonadmin-front> npm installadded 947 packages in 49s102 packages are looking for fundingrun `npm fund` for details
PS D:\front\commonadmin-front> npm run serve> commonadmin-front@0.1.0 serve
> vue-cli-service serveINFO Starting development server...DONE Compiled successfully in 5604ms 15:01:17App running at:- Local: http://localhost:8080/Note that the development build is not optimized.To create a production build, run yarn build.
PS D:\front\commonadmin-front-a> npm install element-ui@2.15.13
npm WARN deprecated core-js@2.6.12: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.added 9 packages in 9s102 packages are looking for fundingrun `npm fund` for details
PS D:\front\commonadmin-front-a>
我这里使用全局引入
可参考element-ui 官网 https://element.eleme.cn/#/zh-CN/component/quickstart
修改main.js 引入element-ui
import Vue from 'vue'
import ElementUI from 'element-ui'; //全局引入element-ui
import 'element-ui/lib/theme-chalk/index.css'; //全局引入element-ui
import App from './App.vue'Vue.use(ElementUI); //全局引入element-ui
Vue.config.productionTip = falsenew Vue({render: h => h(App),
}).$mount('#app')
在app.vue 里加一段代码验证下
![]()
成功引入element-ui //验证element-ui 引入是否成功
注意我这里用的是vue2 ,所以安装vue-router@3 版本
PS D:\front\commonadmin-front-a> npm install vue-router@3added 1 package in 3s102 packages are looking for fundingrun `npm fund` for details
PS D:\front\commonadmin-front-a>
参考官方文档
https://v3.router.vuejs.org/zh/installation.html
可以直接在main.js 里配置,我这里是单独写个router.js ,在该文件里配置,然后把router.js 引入到main.js
router.js
import Vue from 'vue'
import Router from 'vue-router'Vue.use(Router)
main.js
import Vue from 'vue'
import ElementUI from 'element-ui'; //全局引入element-ui
import 'element-ui/lib/theme-chalk/index.css'; //全局引入element-ui
import App from './App.vue'
import router from './router' //引入 vue-routerVue.use(ElementUI); //全局引入element-ui
Vue.config.productionTip = falsenew Vue({router, //引入 vue-routerrender: h => h(App),
}).$mount('#app')
有的项目有单独.eslintrc.js 配置文件,有的没有,
没有的项目大概率在package.json 文件里
"eslintConfig": {"root": true,"env": {"node": true},"extends": ["plugin:vue/essential","eslint:recommended"],"parserOptions": {"parser": "@babel/eslint-parser"},"rules": {"vue/multi-word-component-names":"off"}},
should always be multi-word.eslintvue/multi-word-component-names
加如下配置
"rules": {"vue/multi-word-component-names":"off"}