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 jump to a page in vue.js

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

Share

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

This article mainly introduces how to jump to the page in vue.js, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.

Vue.js page jump method: 1, in DOM respectively set back, forward, jump any page three buttons; 2, in the constructor to manipulate back, forward, jump any page three buttons, the method can be written in methods.

This article operating environment: windows10 system, vue.js 2.5.2, thinkpad T480 computer.

In general, we choose to use tags for page jumps in vue, but we can't directly manipulate DOM elements in the constructor, so how do we do page jumps in this case?

Now let's take a look at the implementation.

Step 1:

Let's first set up three buttons in DOM, which are "back", "forward" and "jump to any page".

Go back, forward, jump to any page.

The next step is to manipulate them in the constructor

When the back button is selected, the page jumps to the previous page

When the forward button is selected, the page jumps to the next page

When you select the Jump any Page button, the page jumps to any jump page

Except for the last jump to any page, the other two buttons need to have traces of history before they can jump.

Of course, the method should be written in methods:

Methods: {goback () {this.$router.go (- 1)}, forwards () {this.$router.go (1)}, goto () {this.$router.push ("/ about")}} Thank you for reading this article carefully. I hope the article "how to jump to a page in vue.js" shared by the editor will be helpful to you. At the same time, I also hope that you will support and pay attention to the industry information channel, and more related knowledge is waiting for you to learn!

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