hookehuyr

update

.DS_Store
node_modules
/dist
# local env files
.env.local
.env.*.local
# Log files
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Editor directories and files
.idea
.vscode
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw*
import axios from 'axios'
import router from './router'
// 请求拦截器
axios.interceptors.request.use(
config => {
// 发送请求前
return config;
},
error => {
// 请求错误处理
return Promise.reject(error);
})
// 响应拦截器
axios.interceptors.response.use(
response => {
return response;
},
error => {
if (error.response) {
switch (error.response.status) {
case 401:
router.replace({
path: '/login'
})
break;
case 404:
router.replace({
path: '/'
})
break;
}
}
return Promise.reject(error.response.data);
})
export default axios;
export default [
{
path: '/',
name: 'home',
component: () => import('./views/Home.vue')
},
{
path: '/about',
name: 'about',
component: () => import('./views/About.vue')
}
]
import Vue from 'vue'
import Router from 'vue-router'
import Home from './views/Home.vue'
import VueRouter from 'vue-router'
import ConfigRouter from './route.js'
Vue.use(Router)
Vue.use(VueRouter)
export default new Router({
routes: [
{
path: '/',
name: 'home',
component: Home
},
{
path: '/about',
name: 'about',
// route level code-splitting
// this generates a separate chunk (about.[hash].js) for this route
// which is lazy-loaded when the route is visited.
component: () => import(/* webpackChunkName: "about" */ './views/About.vue')
}
]
const router = new VueRouter({
history: false,
hashbang: true,
base: __dirname,
routes: ConfigRouter
})
router.beforeEach((to, from, next) => {
// store.commit('updateLoadingStatus', true)
next()
})
router.afterEach((to, from, next) => {
// store.commit('updateLoadingStatus', false)
})
export default router
......
<template>
<div class="home">
<x-header></x-header>
<img alt="Vue logo" src="../assets/logo.png">
<HelloWorld msg="Welcome to Your Vue.js App"/>
</div>
......@@ -8,11 +9,13 @@
<script>
// @ is an alias to /src
import HelloWorld from '@/components/HelloWorld.vue'
import { XHeader } from 'vux'
export default {
name: 'home',
components: {
HelloWorld
HelloWorld,
XHeader
}
}
</script>
......
const vuxLoader = require('vux-loader')
module.exports = {
// 基本路径
publicPath: process.env.NODE_ENV === 'production'
? '/'
: '/boh/',
// vux 相关配置,使用vux-ui
configureWebpack: config => {
vuxLoader.merge(config, {
options: {},
plugins: ['vux-ui']
})
},
// 输出文件目录
outputDir: 'dist',
// eslint-loader 是否在保存的时候检查
lintOnSave: true,
// webpack配置
// see https://github.com/vuejs/vue-cli/blob/dev/docs/webpack.md
chainWebpack: () => {},
// 生产环境是否生成 sourceMap 文件
productionSourceMap: true,
// css相关配置
css: {
// 是否使用css分离插件 ExtractTextPlugin
extract: true,
// 开启 CSS source maps?
sourceMap: false,
// css预设器配置项
loaderOptions: {},
// 启用 CSS modules for all css / pre-processor files.
modules: false
},
// use thread-loader for babel & TS in production build
// enabled by default if the machine has more than 1 cores
parallel: require('os').cpus().length > 1,
// PWA 插件相关配置
// see https://github.com/vuejs/vue-cli/tree/dev/packages/%40vue/cli-plugin-pwa
pwa: {},
// webpack-dev-server 相关配置
devServer: {
open: process.platform === 'darwin',
host: '0.0.0.0',
port: 8080,
https: false,
hotOnly: false,
proxy: null, // 设置代理
before: app => {}
},
// 第三方插件配置
pluginOptions: {
// ...
}
}