编程式路由导航

  1. 作用:不借助<router-link>实现路由跳转,让路由跳转更加灵活

  2. 具体编码:

    //$router的两个API
    this.$router.push({
    	name:'xiangqing',
    	params:{
    		id:xxx,
    		title:xxx
    	}
    })
    
    this.$router.replace({
    	name:'xiangqing',
    	params:{
    		id:xxx,
    		title:xxx
    	}
    })
    this.$router.forward() //前进
    this.$router.back() //后退
    this.$router.go() //可前进也可后退
    

push和replace的区别

push会保留所有的历史记录
replace会将上一个历史记录覆盖

Logo

CSDN联合极客时间,共同打造面向开发者的精品内容学习社区,助力成长!

更多推荐