zoukankan      html  css  js  c++  java
  • vue-cli@2迁移到4

    一、路径别名设置:

    vue-cli@2.x:

     1 // build/webpack.base.conf.js中:
     2 resolve: {
     3     extensions: [".js", ".vue", ".json", ".css", ".scss"],
     4     alias: {
     5       vue$: "vue/dist/vue.esm.js",
     6       "@": resolve("src"),
     7       'assets': resolve("src/assets"),
     8       'styles': resolve("src/assets/styles"),
     9       'common': resolve("src/common")
    10     }
    11   }

    vue-cli@4.x:

     1 // vue.config.js中:
     2 const path = require('path');
     3 module.exports = {
     4     chainWebpack: (config) => {
     5         config.resolve.alias
     6             .set('@', path.join(__dirname, './src'))
     7             .set('assets', path.join(__dirname, './src/assets'))
     8             .set('common', path.join(__dirname, './src/common'))
     9             .set('styles', path.join(__dirname, './src/assets/styles'));
    10     }
    11 };

    二、开发测试路径代理:

    vue-cli@2.x:

     1 // config/index.js中:
     2 module.exports = {
     3   dev: {
     4     proxyTable: {
     5       '/api':{
     6         'target': 'http://192.168.1.105:8080',// 测试线
     7         'pathRewrite': {
     8           '^/api':'/static/data'
     9         }
    10       }
    11     }
    12 }

    vue-cli@4.x:

     1 // vue.config.js中:
     2 module.exports = {
     3     devServer: {
     4         proxy: {
     5             '/api': {
     6                 target: 'http://192.168.1.105:8080', // 测试线
     7                 pathRewrite: {
     8                     '^/api':'/data'
     9                 },
    10             },
    11         },
    12     },
    13 };
  • 相关阅读:
    请求页面
    获取iframe内的元素
    jquery 判断checkbox是否被选中问题
    bootStrap 模板地址
    content
    基于JS的文本验证
    canvas 移动光速特效-
    Swift 语法
    Xcode 8 Swift 类似插件方法
    js整频滚动展示效果(函数节流鼠标滚轮事件)
  • 原文地址:https://www.cnblogs.com/walker-cheng/p/13056408.html
Copyright © 2011-2022 走看看