vue路由帶參傳值跳轉

一、路由跳轉

this.$router.push('跳轉的url)

二、路由帶參傳值跳轉

  1. 參數不在地址欄中顯示
例:http://跳轉的URL
const pageValue = {
	id: this.id
}
this.$router.push({
 	path: '頁面的路徑',
 	name: '頁面的名字',
   params: pageValue,
 })

  1. 參數在地址欄中顯示
例: http://跳轉的URL?id=5
const pageValue = {
	id: this.id
}
this.$router.push({
 	path: '頁面的路徑',
	name: '頁面的名字',
    query: pageValue,
})

三、獲取路由傳的值

id = this.$route.params.id
id = this.$route.query.id
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章