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