Routing ManagerRecord the vue-route name of each jump, and have built-in methods for handling fallbacks, making it easy to fall back to the specified page backgroundIn the projects developed by the author, various fancy jumps are often encountered. For example, from the selection operation on the guide page to the final submission and review, there will be countless pages in the middle, and even different operations in the middle will lead to different final rollback depths. Assume that the starting point of the project is the selection page, and eventually it will reach the submission page and return to the original page (selection page)
At this time, you can use the RouteManager plug-in to handle this series of complex problems getting Startednpm i vue-route-manager -S import Vue from 'vue' // Import the route manager import VueRouteManager from 'vue-route-manager' // and mount it on Vue Vue.use(VueRouteManager, { /* ...ManagerOptions */ }) // At this point in the page you can use this.$RouteManager to access the manager ManagerOptions Parameters
Example Home Page Route information { path: '/home', name: 'home', component: Home } <template> <button @click="jump">Next page</button> </template> <script> export default { methods: { jump(){ //Record the name of the home page this.$RouteManager.setHome('home') this.$router.push({ name: 'page-1' }) } } } </script> Page-1 Page Routing information { path: '/page_1', name: 'page-1', component: Page-1 } <template> <div class="page-1"> page-1 <button @click="$router.push({ name: 'page-2' })">Next page</button> <button @click="$router.replace({ name: 'page-1' })">Redirect</button> </div> </template> Page-2 Route information { path: '/page_2', name: 'page-2', component: Page-2 } <template> <div class="page-2"> page-2 <button @click="$router.push({ name: 'page-3' })">Next page</button> <button @click="backToHome">Back to Home</button> </div> </template> <script> export default { methods: { backToHome(){ // Call backHome to return to the home page of the first record this.$RouteManager.backHome() } } } </script> Page-3 pages Routing information { path: '/page_3', name: 'page-3', component: Page-3 } <template> <div class="page-3"> page-3 <button @click="$backToHome">Back to Home</button> <button @click="backToPage">Back to page-1</button> </div> </template> export default { methods: { backToPage(){ // Call backByName to return to the specified page (must have gone through this page) this.$RouteManager.backByName('page-1') }, backToHome(){ // Call backHome to return to the home page of the first record this.$RouteManager.backHome() } } } </script> Solving the problem
First, call this.$RouteManager.setHome('page-A') or this.$RouteManager.setHome() on page A Then when page B needs to return, call this.$RouteManager.backHome() MethodssetHome([name])
Set the page route name that needs to be returned eventually backHome() Return to the home page and set the home page via setHome backByName(name)
Return to the page with the specified name SummarizeThis concludes this article about vue-route-manager, the perfect solution for Vue routing fallback. For more relevant Vue routing fallback content, please search 123WORDPRESS.COM's previous articles or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future! You may also be interested in:
|
>>: Best Practices Guide for MySQL Partitioned Tables
Execute the command to install the plugin postcss...
Introduction: The configuration of Docker running...
Table of contents Achieve results Complete code +...
After the green version of mysql5.6 is decompress...
Table of contents 1: Build webpack 2. Data hijack...
The user organization has two Windows Server 2008...
Effect: css: .s_type { border: none; border-radiu...
Overview UNION The connection data set keyword ca...
This article uses examples to illustrate the synt...
Scenario: The data in a table needs to be synchro...
Table of contents 1. The role of array: 2. Defini...
For work needs, I need to make a mobile phone adap...
Table of contents 1. Lvs Introduction 2. Lvs load...
Table of contents Summary put first: 🌲🌲 Preface: ...
In the previous article, we introduced: MySQL8.0....