vue中push报错的问题如何解决呢?
Admin 2022-09-13 群英技术资讯 1173 次浏览
当在当前页面中push页面跳转当前页,只是push的参数不同时,只能用字符串拼接,parames和query都不会起作用。不知道为什么。。。
比如说:当前页的url是
/invest/myinvest?page=1&day=0-30`
但是想点击的时候改变参数,所以就
this.$router.push({path:'/invest/myinvest?',query:{page:1,day:'0-30'}})
然而并无卵用。。。。
只能:
this.$router.push("/invest/myinvest?page="+currentPage+"&day="day);
axios.post('/processing/', {})
.then(function (response) {
console.log(response.data);
if (response.data == 'no_processing') {
alert("文章分析失败!");
return;
}else if(response.data=='empty_processing'){
alert("文章数据为空,无法分析!")
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("文章数据为空,无法分析!")
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);
})
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:mmqy2019@163.com进行举报,并提供相关证据,查实之后,将立刻删除涉嫌侵权内容。
猜你喜欢
这篇文章主要介绍了解决vuex改变了state的值,但是页面没有更新的问题,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧
最近项目中使用了minio作为静态资源管理服务,所以简单写一下如何通过minio来上传图片,下面这篇文章主要给大家介绍了关于Vue中通过minio上传文件的相关资料,文中通过实例代码介绍的非常详细,需要的朋友可以参考下
这篇文章主要介绍了有关vue 组件切换,动态组件,组件缓存,在组件化开发模式下,我们会把整个项目拆分成很多组件,然后按照合理的方式组织起来,达到预期效果,下面来看看文章的详细内容
类型相同,基本类型,比较值是否相同。字符串与数值比较,转化为Number。对象与基础类型比较,对象遵循上述转化规则去比较。null与undefined相等。
本文实例讲述了JavaScript原型与原型链用法。分享给大家供大家参考,具体如下
成为群英会员,开启智能安全云计算之旅
立即注册Copyright © QY Network Company Ltd. All Rights Reserved. 2003-2020 群英 版权所有
增值电信经营许可证 : B1.B2-20140078 粤ICP备09006778号 域名注册商资质 粤 D3.1-20240008