1.全局配置css預(yù)編譯語言霜医,如stylus
前提需先安裝stylus,
1.1 npm i stylus-loader
1.2 npm i?stylus
1.3在build/utils.js中更改添加如下(theme.styl為stylus文件牙捉,路徑請(qǐng)根據(jù)實(shí)際更改)
2.配置px2rem
2.1 npm i?px2rem-loader
2.2?在build/utils.js中更改添加
const px2remLoader = {
loader:'px2rem-loader',
options: {
remUnit:16
? }
}
找到generateLoaders函數(shù)更改
const loaders = options.usePostCSS ? [cssLoader,postcssLoader] : [cssLoader]為
const loaders = options.usePostCSS ? [cssLoader,postcssLoader,px2remLoader] : [cssLoader,px2remLoader]
2.3在index.html中引入適配js
<script>
<!--引入px2rem-loader后自動(dòng)將px轉(zhuǎn)化rem-->
(function (win,doc) {
function setSize() {
doc.documentElement.style.fontSize =16*document.documentElement.clientWidth/375+'px'
? ? }
setSize()
win.addEventListener('resize',setSize,false)
})(window,document)
</script>
3.vue跨域配置
3.1在config/index.js中更改
3.2在config/dev.env.js中更改
3.3在config/prod.env.js中更改
3.4在main.js中添加Vue.prototype.baseURL =process.env.API_HOST
3.5請(qǐng)求數(shù)據(jù)時(shí)(如上一步API_HOST配置為http://baidu.com,請(qǐng)求數(shù)據(jù)的接口為http://baidu.com/h.php,則以下可寫為`${this.baseURL}/h.php`,注意這里的``不是單引號(hào),是tab鍵上面那個(gè))