2018-08-16 11:15:49 +08:00
|
|
|
|
# vue-admin-template
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
> 这是一个 极简的 vue admin 管理后台 它只包含了 Element UI & axios & iconfont & permission control & lint,这些搭建后台必要的东西。
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
[线上地址](http://panjiachen.github.io/vue-admin-template)
|
2018-08-16 11:26:11 +08:00
|
|
|
|
|
|
|
|
|
[国内访问](https://panjiachen.gitee.io/vue-admin-template)
|
2017-10-18 15:28:59 +08:00
|
|
|
|
|
|
|
|
|
## Extra
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
如果你想要根据用户角色来动态生成侧边栏和 router,你可以使用改分支[permission-control](https://github.com/PanJiaChen/vue-admin-template/tree/permission-control)
|
2018-08-16 11:08:53 +08:00
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
本项目基于`webpack4`开发,若还想使用`webpack3`开发,请使用该分支[webpack3](https://github.com/PanJiaChen/vue-admin-template/tree/webpack3)
|
2018-08-16 11:08:53 +08:00
|
|
|
|
|
|
|
|
|
## 相关项目
|
|
|
|
|
|
|
|
|
|
[vue-element-admin](https://github.com/PanJiaChen/vue-element-admin)
|
|
|
|
|
|
|
|
|
|
[electron-vue-admin](https://github.com/PanJiaChen/electron-vue-admin)
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
|
|
|
|
写了一个系列的教程配套文章,如何从零构建后一个完整的后台项目:
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
- [手摸手,带你用 vue 撸后台 系列一(基础篇)](https://juejin.im/post/59097cd7a22b9d0065fb61d2)
|
|
|
|
|
- [手摸手,带你用 vue 撸后台 系列二(登录权限篇)](https://juejin.im/post/591aa14f570c35006961acac)
|
|
|
|
|
- [手摸手,带你用 vue 撸后台 系列三 (实战篇)](https://juejin.im/post/593121aa0ce4630057f70d35)
|
|
|
|
|
- [手摸手,带你用 vue 撸后台 系列四(vueAdmin 一个极简的后台基础模板,专门针对本项目的文章,算作是一篇文档)](https://juejin.im/post/595b4d776fb9a06bbe7dba56)
|
|
|
|
|
- [手摸手,带你封装一个 vue component](https://segmentfault.com/a/1190000009090836)
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
|
|
|
|
## Build Setup
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
```bash
|
2017-09-15 14:02:03 +08:00
|
|
|
|
# Clone project
|
2018-08-16 11:19:38 +08:00
|
|
|
|
git clone https://github.com/PanJiaChen/vue-admin-template.git
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
|
|
|
|
# Install dependencies
|
|
|
|
|
npm install
|
|
|
|
|
|
|
|
|
|
# 建议不要用cnpm 安装有各种诡异的bug 可以通过如下操作解决npm速度慢的问题
|
|
|
|
|
npm install --registry=https://registry.npm.taobao.org
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
# Serve with hot reload at localhost:9528
|
2017-09-15 14:02:03 +08:00
|
|
|
|
npm run dev
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
# Build for production with minification
|
2017-09-15 14:02:03 +08:00
|
|
|
|
npm run build
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
# Build for production and view the bundle analyzer report
|
2017-09-15 14:02:03 +08:00
|
|
|
|
npm run build --report
|
|
|
|
|
```
|
|
|
|
|
|
|
|
|
|
## Demo
|
2018-08-16 11:08:53 +08:00
|
|
|
|
|
2017-09-15 14:02:03 +08:00
|
|
|
|
![demo](https://github.com/PanJiaChen/PanJiaChen.github.io/blob/master/images/demo.gif)
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
### Element-Ui 使用 cdn 教程
|
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
首先找到 `index.html` ([根目录下](https://github.com/PanJiaChen/vue-admin-template/blob/element-ui-cdn/index.html))
|
2018-05-14 10:48:27 +08:00
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
引入 Element 的 css 和 js ,并且引入 vue 。因为 Element-Ui 是依赖 vue 的,所以必须在它之前引入 vue 。
|
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
之后找到 [webpack.base.conf.js](https://github.com/PanJiaChen/vue-admin-template/blob/element-ui-cdn/build/webpack.base.conf.js) 加入 `externals` 让 webpack 不打包 vue 和 element
|
2018-05-14 10:48:27 +08:00
|
|
|
|
|
|
|
|
|
```
|
|
|
|
|
externals: {
|
|
|
|
|
vue: 'Vue',
|
|
|
|
|
'element-ui':'ELEMENT'
|
|
|
|
|
}
|
|
|
|
|
```
|
|
|
|
|
|
2018-08-16 11:08:53 +08:00
|
|
|
|
之后还有一个小细节是如果你用了全局对象方式引入 vue,就不需要 手动 `Vue.use(Vuex)` ,它会自动挂载,具体见 [issue](https://github.com/vuejs/vuex/issues/731)
|
2018-05-14 10:48:27 +08:00
|
|
|
|
|
|
|
|
|
最终你可以使用 `npm run build --report` 查看效果
|
|
|
|
|
如图:
|
|
|
|
|
![demo](https://panjiachen.github.io/images/element-cdn.png)
|
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
**[具体代码](https://github.com/PanJiaChen/vue-admin-template/commit/746aff560932704ae821f82f10b8b2a9681d5177)**
|
2018-05-14 10:48:27 +08:00
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
**[对应分支](https://github.com/PanJiaChen/vue-admin-template/tree/element-ui-cdn)**
|
2018-05-14 10:48:27 +08:00
|
|
|
|
|
2017-09-15 14:02:03 +08:00
|
|
|
|
## License
|
2018-08-16 11:08:53 +08:00
|
|
|
|
|
2018-08-16 11:19:38 +08:00
|
|
|
|
[MIT](https://github.com/PanJiaChen/vue-admin-template/blob/master/LICENSE) license.
|
2017-09-15 14:02:03 +08:00
|
|
|
|
|
2018-01-02 10:07:55 +08:00
|
|
|
|
Copyright (c) 2017-present PanJiaChen
|