vue的config配置問題 以及 Refused to load the image 'http://localhost:8080/favicon.ico'


在文件夾config的index.js中配置dev和build

打包問題

  dev: {
    // Various Dev Server settings
    host: '127.0.0.1', // can be overwritten by process.env.HOST
    port: 80, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
    // Paths
    assetsSubDirectory: 'static',
    // 相對 絕對路徑問題
    assetsPublicPath: '/',
    // proxyTable: {},
    proxyTable: {
      '/api': {
        // 測試
        target: 'http://47.105.107.186:8889',
        // 最新的開發環境
        // target: 'http://192.168.1.156:8889',
        // target: 'http://47.104.71.52:8889',
        // secure: false,  // 如果是https接口,需要配置這個參數
        changeOrigin: true,
        pathRewrite: {
          '^/api': '', //地址重寫,省略api 看的格式正確
        }
      },
    },
    autoOpenBrowser: false,
    errorOverlay: true,
    notifyOnErrors: true,
    poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-

    /**
     * Source Maps
     */

    // https://webpack.js.org/configuration/devtool/#development
    devtool: 'cheap-module-eval-source-map',

    // If you have problems debugging vue-files in devtools,
    // set this to false - it *may* help
    // https://vue-loader.vuejs.org/en/options.html#cachebusting
    cacheBusting: true,

    cssSourceMap: true
  },
  build: {
    index: path.resolve(__dirname, '../dist/index.html'),
    assetsSubDirectory: 'static',
    assetsPublicPath: './', //這行是改變的
}


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM