详解vue-cli 构建Vue项目遇到的坑
前言使用Vue做管理系统和WebApp做过三四个项目了,期间遇到很多坑,再次一一列举,并给出解决方案,方便日后更方便使用,也为他人提供一些解决方案。 问题表象和解决方案1、编译后js、css等相对路径和绝对路径。
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中图片相对路径编译后,路径不对。3、使用代理,解决跨域请求。vue-cli已经集成 http-proxy-middleware插件 github:https://github.com/chimurai/http-proxy-middleware 其中 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。 以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持编程之家。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |