前言
使用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。
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
华山资源网 Design By www.eoogi.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
华山资源网 Design By www.eoogi.com
暂无评论...
更新日志
2024年09月25日
2024年09月25日
- 纯音入心系列纯音乐《天籁古筝》1CD[MP3][331MB]
- 男女对唱典藏天碟《发烧对唱·那个季节里的歌DSD》10CD[WAV]
- 群星2010-歌林精选辑[歌林][WAV+CUE]
- TrioZimbalist-PianoTriosofWeinberg,Auerbach,Dvorak(2024)[24-44,1]wav
- 群星.1992-滚石第一流台湾歌·12王牌大车拼【滚石】【WAV+CUE】
- 林子祥.1984-创作歌集【华纳】【WAV+CUE】
- 周汤豪.2010-周汤豪【华纳】【FLAC分轨】
- Mozart-TheStringQuintets-AmadeusQuartet,CecilAronowitz(2017)[24-44,1][WAV+CUE]
- JamesWilliamsDennisIrwin-Focus(2024,Red)[24-48]FLAC
- 藤泽麻衣《空みあげて》[WAV]
- 纯音入心系列纯音乐《中国古筝经典名曲》1CD[MP3][1.3GB]
- 纯音入心系列纯音乐《古筝新奏:岁月静好与筝语,细水流年与筝同》1CD[MP3][846.9MB]
- 670《脆弱敏感小女生》[320K/MP3][27.53MB]
- 曾琳.2011-好好爱我【南方】【WAV+CUE】
- 范晓萱.1995-RAIN【福茂】【WAV+CUE】