lang="less"報(bào)錯(cuò)梗夸,原因是less-loader版本過高
解決辦法:將less-loader的版本降低
1儿倒、在package.js中找到less-loader,將版本號改為 ^5.0.0;
2距糖、然后再執(zhí)行npm install less-loader@5.0.0 --save玄窝。
https://blog.csdn.net/l244112311/article/details/105844036
axios.defaults.withCredentials = true;
- 默認(rèn)情況下,跨源請求不提供憑據(jù)(cookie悍引、HTTP認(rèn)證及客戶端SSL證明等)恩脂。通過將withCredentials屬性設(shè)置為true,可以指定某個(gè)請求應(yīng)該發(fā)送憑據(jù)趣斤。
- 后端需要帶cookie過去俩块,而前端沒有設(shè)置為true,所以導(dǎo)致cookie傳不過去
- 當(dāng)配置了 withCredentials = true時(shí)浓领,必須在后端增加 response 頭信息Access-Control-Allow-Origin玉凯,且必須指定域名,而不能指定為*A贰B汀!
https://www.cnblogs.com/hehuiqiong/p/13132226.html - vue不會(huì)自動(dòng)保存后端傳來的cookie
https://blog.csdn.net/qq_39611230/article/details/108090828
Vuex namespaced: true配置
- 使其成為帶命名空間的模塊撑蒜。保證在變量名一樣的時(shí)候歹啼,添加一個(gè)父級名拼接
https://blog.csdn.net/qq_40410916/article/details/108121892
Uncaught TypeError: routes.forEach is not a function
- 路由配置錯(cuò)誤,獲取不到
https://blog.csdn.net/qq_41337100/article/details/105330860
vue創(chuàng)建項(xiàng)目報(bào)錯(cuò)
Command vue init requires a global addon to be installed.
Please run yarn global add @vue/cli-init
- 解決辦法:先執(zhí)行以下命令
npm install -g @vue/cli-init
https://blog.csdn.net/weixin_42886893/article/details/107022876
less報(bào)錯(cuò)
* !!vue-style-loader!css-loader?{"sourceMap":true}
!../../node_modules/vue-loader/lib/style-compiler/index? .......
- 原因:缺少相關(guān)依賴
- 解決辦法:npm install less less-loader --save-dev
http://www.reibang.com/p/72e3af3fa747
vue項(xiàng)目打包后座菠,dist里有文件報(bào)錯(cuò)404
- 修改config/index.js
assetsPublicPath: './' // 將'/'改成'./'
https://blog.csdn.net/miss_liangrm/article/details/98534134
- 如果router里設(shè)置了base值狸眼,則設(shè)置為該目錄
const router = new Router({
base: 'treat',
mode: 'history'
});
assetsPublicPath: '/treat/' // ***
Vue+elementUI build打包后字體圖標(biāo)丟失問題
解決辦法:
build目錄下utils.js,添加 publicPath: '../../'
if (options.extract) {
return ExtractTextPlugin.extract({
use: loaders,
fallback: 'vue-style-loader',
publicPath: '../../' // 修改
})
} else {
return ['vue-style-loader'].concat(loaders)
}
https://blog.csdn.net/qq_38543537/article/details/90755830
vue配置dev浴滴、test拓萌、pro環(huán)境,實(shí)現(xiàn)分環(huán)境打包
https://www.pianshen.com/article/57691807884/
webpack 在index.html里面區(qū)分環(huán)境變量(process.env.NODE_ENV)
<script>
if ('<%= process.env.NODE_ENV %>' === 'development') {
window.SITE_CONFIG['apiURL'] = '/api'; // prod_api // api請求地址
} else {
window.SITE_CONFIG['apiURL'] = '/prod_api'; //
}
</script>
https://blog.csdn.net/xiaomogg/article/details/102549753
網(wǎng)頁title的logo小圖標(biāo)
- 圖片需要放在static里引入升略,本地才會(huì)展示
<link rel="shortcut icon" type="image/x-icon" href="./static/img/logo.png" />
PC端網(wǎng)頁基本設(shè)置
<title>標(biāo)題</title>
<meta name="description" content='內(nèi)容長一點(diǎn)' />
<meta name="keywords" content='內(nèi)容短一點(diǎn)' />
<link rel="shortcut icon" type="image/x-icon" href="./static/img/logo.png"/>
移動(dòng)端網(wǎng)頁適配
<meta id="viewport" content="width=device-width, user-scalable=yes,initial-scale=1" name="viewport" />
<script>
var detectBrowser = function(name) {
if (navigator.userAgent.toLowerCase().indexOf(name) > -1) {
return true;
} else {
return false;
}
};
var width = parseInt(window.screen.width);
var scale = width / 640; // 根據(jù)設(shè)計(jì)稿尺寸進(jìn)行相應(yīng)修改:640=>?
var userScalable = 'no';
if (detectBrowser("qq/")) userScalable = 'yes';
document.getElementById('viewport').setAttribute(
'content', 'target-densitydpi=device-dpi,width=1445,user-scalable=' + userScalable + ',initial-scale=' + scale); // 這里也別忘了改:640=>?
</script>
https://www.jb51.net/article/110711.htm
npm run build 打包報(bào)錯(cuò)
解決方案:npm 更新到最新版本
npm install npm@latest
https://blog.csdn.net/q709984620/article/details/105699364
axios post請求出現(xiàn)兩次
多了一個(gè)看似無效的OPTIONS請求微王。這里其實(shí)是一次"預(yù)檢"請求,瀏覽器先詢問服務(wù)器品嚣,當(dāng)前網(wǎng)頁所在的域名是否在服務(wù)器的許可名單之中炕倘,以及可以使用哪些HTTP動(dòng)詞和頭信息字段。只有得到肯定答復(fù)翰撑,瀏覽器才會(huì)發(fā)出正式的XMLHttpRequest請求罩旋,否則就報(bào)錯(cuò)。
- 產(chǎn)生跨域的原因是因?yàn)榭粽_發(fā)前端vue項(xiàng)目時(shí)要開端口涨醋,后端服務(wù)也要開端口,然后端口不同逝撬,產(chǎn)生了跨域浴骂。又因?yàn)閏ontent-type為application/json;charset=UTF-8 ,所以就有 options 請求宪潮。當(dāng)項(xiàng)目打包上線后就沒跨域了溯警,options自然就沒了