国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

詳解vue-cli 構建Vue項目遇到的坑

2019-11-19 15:36:22
字體:
來源:轉載
供稿:網友

前言

使用Vue做管理系統和WebApp做過三四個項目了,期間遇到很多坑,再次一一列舉,并給出解決方案,方便日后更方便使用,也為他人提供一些解決方案。

問題表象和解決方案

1、編譯后js、css等相對路徑和絕對路徑。

config/inde.js文件 build: {  env: require('./prod.env'),  index: path.resolve(__dirname, '../dist/index.html'),  assetsRoot: path.resolve(__dirname, '../dist'),  assetsSubDirectory: 'static',  assetsPublicPath: './', // "./"表示相對路徑 編譯結果 <link href=./static/css/app.518fd3471fd03bfce5524de6e934771c.css rel=stylesheet>  productionSourceMap: true,  // Gzip off by default as many popular static hosts such as  // Surge or Netlify already gzip all static assets for you.  // Before setting to `true`, make sure to:  // npm install --save-dev compression-webpack-plugin  productionGzip: false,  productionGzipExtensions: ['js', 'css'],  // Run the build command with an extra argument to  // View the bundle analyzer report after build finishes:  // `npm run build --report`  // Set to `true` or `false` to always turn it on or off  bundleAnalyzerReport: process.env.npm_config_report },

2、CSS中圖片相對路徑編譯后,路徑不對。

//同常路徑表現為 ./static/img/static/img/*.jpg (定義為imgurl)解決方案 修改build/untils.js//替換相應代碼if (options.extract) {   return ExtractTextPlugin.extract({    use: loaders,    publicPath: '../../', //注意: 此處根據路徑, 自動更改 ,(imgurl='static/img/*.jpg')    fallback: 'vue-style-loader'   })  } else {   return ['vue-style-loader'].concat(loaders)  }

3、使用代理,解決跨域請求。

vue-cli已經集成 http-proxy-middleware插件

github:https://github.com/chimurai/http-proxy-middleware

proxyTable: {   '/dianmi_service': {    target: 'https://****.com.cn',    changeOrigin: true   },   '/brand_service': {    target: 'https://*****.com.cn',    changeOrigin: true   }  },

其中 target的值一定不可以包含工程名,否則可能會出現服務器Session問題

4、用Vue做頁面,利用phonegap編譯android APP時,兼容問題。

cordova android 4.0 以下的默認webView,不支持ES6,會導致一些列問題。

好在,cordova android允許我們自定義自己的webView引擎。那么我們就想到了 騰訊瀏覽服務X5內核。

然而有大神基于此內核編寫了cordova 插件

githup:https://github.com/offbye/cordova-plugin-x5engine-webview

使用此插件很好的解決 低版本安卓不支持Vue。

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持武林網。

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 葫芦岛市| 阿荣旗| 宁德市| 长寿区| 阿拉善左旗| 台中市| 白水县| 政和县| 潼南县| 洛浦县| 临澧县| 沈阳市| 平湖市| 安多县| 舞钢市| 福鼎市| 白银市| 安福县| 金塔县| 革吉县| 南昌市| 泰兴市| 抚顺市| 佛冈县| 平度市| 曲阳县| 宣汉县| 镇宁| 原阳县| 临漳县| 兰考县| 丰都县| 贵港市| 广河县| 桦川县| 达拉特旗| 临西县| 德安县| 福贡县| 东乌珠穆沁旗| 墨玉县|