vue项目配置篇

361 阅读1分钟

src目录路径简写配置

根目录下创建jsconfig.json文件,并进行如下配置

{ "compilerOptions": { "baseUrl": "./", "paths": { "@/*":[ "src/*" ] } }, "exclude": [ "node_modules", "dist" ] }

路由配置依赖注入

new Vue({ render: h => h(App), router }).$mount('#app')

关闭语法检查

根目录下创建vue.config.js文件并进行如下配置

module.exports = { // 关闭eslint lintOnSave: false }

配置路由重定向

{ path: "*", redirect: "/Home" }

配置代理

通过vue-cli内置的代理配置较为简单,在根目录下创建vue.config.js文件,并做如下配置,设置代理ip及路径重定向

module.exports = {
  devServer: {
    proxy: {
      '/api': {
        target: '<url>',
        ws: true,
        changeOrigin: true
      },
      '/foo': {
        target: '<other_url>'
      }
    }
  }
}