vue實力踩坑?當(dāng)前頁push當(dāng)前頁無效的解決
vue當(dāng)前頁push當(dāng)前頁無效
當(dāng)在當(dāng)前頁面中push頁面跳轉(zhuǎn)當(dāng)前頁,只是push的參數(shù)不同時,只能用字符串拼接,parames和query都不會起作用。不知道為什么。。。
比如說:當(dāng)前頁的url是
/invest/myinvest?page=1&day=0-30`
但是想點擊的時候改變參數(shù),所以就
this.$router.push({path:'/invest/myinvest?',query:{page:1,day:'0-30'}})然而并無卵用。。。。
只能:
this.$router.push("/invest/myinvest?page="+currentPage+"&day="day);vue push報錯
TypeError: Cannot read property ‘push‘ of undefined
axios.post('/processing/', {})
.then(function (response) {
console.log(response.data);
if (response.data == 'no_processing') {
alert("文章分析失敗!");
return;
}else if(response.data=='empty_processing'){
alert("文章數(shù)據(jù)為空,無法分析!")
return;
}
response.data.forEach(function(element){
this.processing_tableData.push(element); //“push”報錯
console.log(element);
});
console.log("ok_processing")
})
.catch(function (error) {
console.log(error);
})
報錯:
TypeError: Cannot read property ‘push’ of undefined
解決方法
在外部定義一個值指代Vue實例
var self = this; //外部定義
axios.post('/processing/', {})
.then(function (response) {
console.log(response.data);
if (response.data == 'no_processing') {
alert("文章分析失??!");
return;
}else if(response.data=='empty_processing'){
alert("文章數(shù)據(jù)為空,無法分析!")
return;
}
response.data.forEach(function(element){
self.processing_tableData.push(element); //把“this”=》“self”
console.log(element);
});
console.log("ok_processing")
})
.catch(function (error) {
console.log(error);
})
以上為個人經(jīng)驗,希望能給大家一個參考,也希望大家多多支持腳本之家。
相關(guān)文章
適用于 Vue 的播放器組件Vue-Video-Player操作
這篇文章主要介紹了適用于 Vue 的播放器組件Vue-Video-Player操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-11-11
vue3封裝AES(CryptoJS)前端加密解密通信代碼實現(xiàn)
防止數(shù)據(jù)被爬取,前后端傳參接收參數(shù)需要加密處理,使用AES加密,這篇文章主要給大家介紹了關(guān)于vue3封裝AES(CryptoJS)前端加密解密通信代碼實現(xiàn)的相關(guān)資料,需要的朋友可以參考下2023-12-12
Vue Echarts實現(xiàn)圖表的動態(tài)適配以及如何優(yōu)化
這篇文章主要介紹了Vue Echarts實現(xiàn)圖表的動態(tài)適配以及如何優(yōu)化,在實際的前端開發(fā)過程中,動態(tài)適配是一個非常重要的問題,在數(shù)據(jù)可視化的場景下,圖表的動態(tài)適配尤為重要,需要的朋友可以參考下2023-05-05

