vue point on the route easy to overlook

1, remove the navigation Lane #

    In the router.js

export default new Router{
          mode:'history'
      }

2, class designated activate items

In the router.js

export default new Router{
   linkActiveClass:'active'
}

You can set the class of active in the css.

3, the jump tag type designated

 

<li><router-link to="/home">主页</router-link></li>

In the printing is a label

If you want to is not a label, you can add tag

<li><router-link tag="div" to="/home">主页</router-link></li>

 a div tag will be replaced

4, as the routing address by property name

<li><router-link :to="homeLink">主页</router-link></li>
<script>
       export default {
		data(){
			return {
				homeLink:'/home'
			}
		}
</script>

5, to route a name, but also jump

<li><router-link :to="{name:'homeLink'}">主页</router-link></li>

  In the router.js

{path:'/home',name:'homeLink',component:Home},

6, routing jump method

1) rollback and jump to

<div> 
        <h2> This is Home </ h2> 
        <@ the Click the Button = "the Back"> fallback </ the Button> 
        <@ the Click the Button = "goTo"> Go to </ the Button> 
    </ div>

  

<Script> 
    Export default { 
        Methods: { 
            Back () { 
                . router.go the this $ (-1); // fall back on the last open page 
            }, 
            goTo () { 
                . router.replace the this $ ( '/ Manage '); // jump to another address 
                the this router.replace $ ({name:.' dishesLink '}); 
                the this $ router.push (.' / Order '); // specified jump to 
                this $ router.. Push ({name: 'dishesLink'}); 
            } 
        } 
    } 
</ Script>

 7, redirect to the home page

In the router.js

{path:'*',redirect:'/home'}

  

 

  

Guess you like

Origin www.cnblogs.com/colorful-paopao1/p/11417857.html