小編給大家分享一下vue-cli構(gòu)建Vue項(xiàng)目遇到的問題有哪些,希望大家閱讀完這篇文章之后都有所收獲,下面讓我們一起去探討吧!
網(wǎng)站建設(shè)哪家好,找創(chuàng)新互聯(lián)建站!專注于網(wǎng)頁設(shè)計(jì)、網(wǎng)站建設(shè)、微信開發(fā)、微信平臺(tái)小程序開發(fā)、集團(tuán)企業(yè)網(wǎng)站建設(shè)等服務(wù)項(xiàng)目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了新吳免費(fèi)建站歡迎大家使用!
問題表象和解決方案
1、編譯后js、css等相對(duì)路徑和絕對(duì)路徑。
config/inde.js文件 build: { env: require('./prod.env'), index: path.resolve(__dirname, '../dist/index.html'), assetsRoot: path.resolve(__dirname, '../dist'), assetsSubDirectory: 'static', assetsPublicPath: './', // "./"表示相對(duì)路徑 編譯結(jié)果 <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中圖片相對(duì)路徑編譯后,路徑不對(duì)。
//同常路徑表現(xiàn)為 ./static/img/static/img/*.jpg (定義為imgurl) 解決方案 修改build/untils.js //替換相應(yīng)代碼 if (options.extract) { return ExtractTextPlugin.extract({ use: loaders, publicPath: '../../', //注意: 此處根據(jù)路徑, 自動(dòng)更改 ,(imgurl='static/img/*.jpg') fallback: 'vue-style-loader' }) } else { return ['vue-style-loader'].concat(loaders) }
3、使用代理,解決跨域請(qǐng)求。
vue-cli已經(jīng)集成 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的值一定不可以包含工程名,否則可能會(huì)出現(xiàn)服務(wù)器Session問題
4、用Vue做頁面,利用phonegap編譯android APP時(shí),兼容問題。
cordova android 4.0 以下的默認(rèn)webView,不支持ES6,會(huì)導(dǎo)致一些列問題。
好在,cordova android允許我們自定義自己的webView引擎。那么我們就想到了 騰訊瀏覽服務(wù)X5內(nèi)核。
然而有大神基于此內(nèi)核編寫了cordova 插件
githup:https://github.com/offbye/cordova-plugin-x5engine-webview
使用此插件很好的解決 低版本安卓不支持Vue。
看完了這篇文章,相信你對(duì)“vue-cli構(gòu)建Vue項(xiàng)目遇到的問題有哪些”有了一定的了解,如果想了解更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!
當(dāng)前名稱:vue-cli構(gòu)建Vue項(xiàng)目遇到的問題有哪些
網(wǎng)站URL:http://chinadenli.net/article18/gphdgp.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供響應(yīng)式網(wǎng)站、網(wǎng)站建設(shè)、靜態(tài)網(wǎng)站、網(wǎng)站排名、小程序開發(fā)、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)