av一区二区在线观看_亚洲男人的天堂网站_日韩亚洲视频_在线成人免费_欧美日韩精品免费观看视频_久草视

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作

瀏覽:9日期:2022-11-25 14:20:49

很多情況下,我們?cè)趫?zhí)行點(diǎn)擊按鈕跳轉(zhuǎn)頁(yè)面之前還會(huì)執(zhí)行一系列方法,這時(shí)可以使用 this.$router.push(location) 來(lái)修改 url,完成跳轉(zhuǎn)。

push 后面可以是對(duì)象,也可以是字符串:

// 字符串this.$router.push(’/home/first’)// 對(duì)象this.$router.push({ path: ’/home/first’ })// 命名的路由this.$router.push({ name: ’home’, params: { userId: wise }})

跳轉(zhuǎn)頁(yè)面并傳遞參數(shù)的方法:

1.Params

由于動(dòng)態(tài)路由也是傳遞params的,所以在 this.$router.push() 方法中path不能和params一起使用,否則params將無(wú)效。需要用name來(lái)指定頁(yè)面。

及通過(guò)路由配置的name屬性訪問(wèn)

在路由配置文件中定義參數(shù):

/* router.js 文件*/import Vue from 'vue';import Router from 'vue-router';import MediaSecond from '@/views/EnterprisePage/MediaMatrix/second'; //資訊列表 Vue.use(Router);export default new Router({ routes: [ /* 進(jìn)行路由配置 */ { name: 'MediaSecond', path: '/MediaSecond', component: MediaSecond }, ]}) /* 后面還需要接一空行,否則無(wú)法通過(guò) ESlint 語(yǔ)法驗(yàn)證 */

通過(guò)name獲取頁(yè)面,傳遞params:

this.$router.push({ name: ’MediaSecond’,params:{artistName:artistName,imgUrl:imgUrl,type:2} })

在目標(biāo)頁(yè)面通過(guò)this.$route.params獲取參數(shù):

if (this.$route.params.type == 2) { this.type = apis.getAtistDetails;} else { this.type = apis.getMessageList;}

2.Query

頁(yè)面通過(guò)path/name和query傳遞參數(shù),該實(shí)例中row為某行表格數(shù)據(jù)

this.$router.push({ name: ’DetailManagement’, query: { auditID: row.id, type: ’2’ } });

this.$router.push({ path: ’/DetailManagement’, query: { auditID: row.id, type: ’2’ } });

在目標(biāo)頁(yè)面通過(guò)this.$route.query獲取參數(shù):

this.$route.query.type

補(bǔ)充知識(shí):vue this.$router.push(’./map’);無(wú)法跳轉(zhuǎn)的問(wèn)題

<template> <div style='text-align: center'> <el-button type='primary' @click='onLogin'>登錄</el-button> </div></template><script> export default { name: ’login’, data () return { } }, methods: { onLogin:function () { this.$router.push(’./map’); } }, }</script><style scoped> </style>

router中是這樣引入的

import map from ’@components/map’

點(diǎn)擊事件無(wú)法跳轉(zhuǎn)

2.解決方法:

改變引入方式

import map=r=>require.ensure([],()=>(require(’../components/map’)),’map’)

這樣通過(guò)靜態(tài)引入就沒(méi)問(wèn)題了!

以上這篇Vue this.$router.push(參數(shù))實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)操作就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 女人黄网站 | 综合久久99 | 91在线小视频 | 精品国产福利 | 综合五月| 国产欧美在线观看 | 欧美激情综合 | 成人扒开伸进免费观看 | 日韩毛片视频 | 中国一级毛片 | 黄色片网站免费 | 亚洲特级片 | 一区二区三区在线播放 | 九九热这里有精品 | 欧美日韩成人 | 久久国内视频 | 午夜精品在线 | 国产日韩欧美一区 | 国产成人tv | 精品在线一区 | 少妇高潮毛片 | 成人看片网 | 特级丰满少妇一级aaaa爱毛片 | 国产寡妇亲子伦一区二区三区四区 | 精品成人在线 | 亚洲777| 中文字幕免费在线看线人动作大片 | 欧美日韩激情视频 | 在线观看日韩精品 | 欧美日韩精品 | 国产黄a| 玖玖色资源 | 国产在线天堂 | 国产成人精品亚洲 | 91av视频在线 | 天天操综合 | 涩五月婷婷 | 色综合天天综合网天天狠天天 | 怡红院久久 | 青青草免费在线观看视频 | 国产精品久久久久久久成人午夜 |