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`
但是想點(diǎn)擊的時候改變參數(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)文章
Element?UI?Upload?組件上傳圖片可刪除、預(yù)覽功能
這篇文章主要介紹了Element?UI?Upload?組件?上傳圖片可刪除、預(yù)覽,設(shè)置只允許上傳單張?/?多張圖片的操作,本文通過實例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-11-11Vue中computed屬性和watch,methods的區(qū)別
本文主要介紹了Vue中computed屬性和watch,methods的區(qū)別,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2023-05-05使用vue打包時vendor文件過大或者是app.js文件很大的問題
這篇文章主要介紹了使用vue打包時vendor文件過大或者是app.js文件很大問題的解決方法,非常不錯,具有一定的參考借鑒價值,需要的朋友可以參考下2018-06-06詳解Vue中的render:?h?=>?h(App)示例代碼
這篇文章主要介紹了Vue中的render:?h?=>?h(App),本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-09-09Vue中金額、日期格式化插件@formatjs/intl的使用及說明
這篇文章主要介紹了Vue中金額、日期格式化插件@formatjs/intl的使用及說明,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2023-02-02Vue中router-view和component :is的區(qū)別解析
這篇文章主要介紹了Vue中router-view和component :is的區(qū)別解析,router-view用法直接填寫跳轉(zhuǎn)路由,路由組件會渲染<router-view></router-view>標(biāo)簽,本文給大家介紹的非常詳細(xì),需要的朋友可以參考下2023-10-10