VUE 中页面跳转的方式


一、router-link标签跳转 (声明式)

 <router-link to='xxx.html'><button>点我到新页面</button></router-link>

  

二、绑定点击事件跳转 (编程式)

  1、先绑定newPage()方法

<button @click="newPage">回到首页</button>

  2、在script模块里加入newPage方法,并用this.$router.push(‘/’)导航到新页面

export default {
    name: 'app',
    methods: {
        newPage(){
            this.$router.push('/dashboard');//或者 this.$router.push({ path:'/new.html'})
        }
    }
}

  三、其他

//  后退一步记录,等同于 history.back()
this.$router.go(-1)

  


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM