# vue admin template 自己不断修改的vue admin 模板 ## 全局的form表单验证 ```html 提交 ``` ## 需要共享的全局枚举参数 > 全部放在`@/utils/enum.js`里面,已全部挂载到Vue.prototype下面 ## 需要共享的全局方法 > 全部放在`@/utils/filter.js`里面,已全部挂载到Vue.prototype下面 ## 所有的api请求 > 统一的axios参数在`@/api/index.js`下面,已全部挂载到Vue.prototype下面 ```js // 具体使用方法,例: // methods: { async handleSubmit() { this.$refs.form.validate(async valid => { if (valid) { // this.$fetch第三个参数可选,默认'post',如果是使用get方法,第三个参数传'get' const data = await this.$fetch('/v1/front/otherApi', { ...this.form}) if (data.code === 0) { this.$message.success('提交成功') this.$emit('success') this.dialog = false } else { this.reloadImg() } } }) }, } ``` ## dialog弹窗 > dialog弹窗尽量使用组件引入,dialog例子在`@/components/_dialog/exampleDialog`里面 ```html ``` ## 表格统一分页,统一风格 > 使用`@/mixin/page.js` 使用前最好看一下 > 下面例子包含了表格统一和全局枚举(enum)的应用 ```js // 页面引用js部分 import page from '@/mixin/page' export default { mixins: [page], data() { return { time: [], searchForm: {}, tableData: [], tableUrl: '/v1/front/user/list' } }, methods: { }, mounted () { this.init() }, } ``` ```html ``` ## other 1. 有一些不需要放在vuex下面的,可以使用事件总线$bus,在`@/utils/vue-bus.js`里面。 ## 需要node环境,最好在v10以上 --- ### npm可以用,最好使用yarn ```bash #npm 更换淘宝源 npm config set registry https://registry.npm.taobao.org # 安装yarn npm install yarn -g #yarn 更换淘宝源 yarn config set registry https://registry.npm.taobao.org -g #yarn 和 npm 设置 node-sass 参数 npm config set sass_binary_site=s://npm.taobao.org/mirrors/node-sass/ -g yarn config set sass_binary_site https://npm.taobao.org/mirrors/node-sass/ -g #npm 和 yarn 都设置一下puppeteer的下载参数 (暂时还不需要,如使用puppeteer服务器预渲染则需要设置) // npm config set puppeteer_download_host=https://npm.taobao.org/mirrors // yarn config set puppeteer_download_host https://npm.taobao.org/mirrors ``` ### 安装依赖 ```bash yarn ## or npm i ``` ### 如果涉及到服务器预渲染,就需要下面依赖 ```bash # ubuntu sudo apt install -y gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget #centos sudo yum install pango.x86_64 libXcomposite.x86_64 libXcursor.x86_64 libXdamage.x86_64 libXext.x86_64 libXi.x86_64 libXtst.x86_64 cups-libs.x86_64 libXScrnSaver.x86_64 libXrandr.x86_64 GConf2.x86_64 alsa-lib.x86_64 atk.x86_64 gtk3.x86_64 ipa-gothic-fonts xorg-x11-fonts-100dpi xorg-x11-fonts-75dpi xorg-x11-utils xorg-x11-fonts-cyrillic xorg-x11-fonts-Type1 xorg-x11-fonts-misc ``` ### 最后 打包 ```bash npm run build ## or yarn build ```