Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to solve the problem that the current page in vue push is invalid

2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the "vue current page push current page invalid how to solve" related knowledge, editor through the actual case to show you the process of operation, the method of operation is simple and fast, practical, hope that this "vue current page push current page invalid how to solve" article can help you solve the problem.

Vue current page push current page is invalid

When the push page jumps to the current page in the current page, but the parameters of push are different, you can only use string concatenation, parames and query will not work. I don't know why.

For example, the url of the current page is

/ invest/myinvest?page=1&day=0-30`

But you want to change the parameters when you click, so

This.$router.push ({path:'/invest/myinvest?',query: {page:1,day:'0-30'}})

However, there is no use for eggs.

Only:

This.$router.push ("/ invest/myinvest?page=" + currentPage+ "& day=" day); vue push error TypeError: Cannot read property 'push' of undefinedaxios.post (' / processing/', {}). Then (function (response) {console.log (response.data); if (response.data = = 'no_processing') {alert ("article analysis failed!") ; return;} else if (response.data=='empty_processing') {alert ("the article data is empty and cannot be analyzed!") Return;} response.data.forEach (function (element) {this.processing_tableData.push (element); / / "push" error console.log (element);}); console.log ("ok_processing")}) .catch (function (error) {console.log (error);})

Error report:

TypeError: Cannot read property 'push' of undefined

Solution method

Define a value externally to refer to the Vue instance

Var self = this; / / external definition axios.post ('/ processing/', {}). Then (function (response) {console.log (response.data); if (response.data = = 'no_processing') {alert ("article analysis failed!") ; return;} else if (response.data=='empty_processing') {alert ("the article data is empty and cannot be analyzed!") Return;} response.data.forEach (function (element) {self.processing_tableData.push (element); / / put "this" = "self" console.log (element); console.log ("ok_processing")}) .catch (function (error) {console.log (error)) }) this is the end of the content about "how to solve the invalid push current page in vue". Thank you for your reading. If you want to know more about the industry, you can follow the industry information channel. The editor will update different knowledge points for you every day.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report