国产成人精品久久免费动漫-国产成人精品天堂-国产成人精品区在线观看-国产成人精品日本-a级毛片无码免费真人-a级毛片毛片免费观看久潮喷

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

vue跳轉(zhuǎn)頁(yè)面的幾種方法(推薦)

瀏覽:2日期:2023-01-29 15:00:03

vue跳轉(zhuǎn)不同頁(yè)面的多種方法

1:router-link跳轉(zhuǎn)

<!-- 直接跳轉(zhuǎn) --><router-link to=’/testDemo’> <button>點(diǎn)擊跳轉(zhuǎn)2</button></router-link> <!-- 帶參數(shù)跳轉(zhuǎn) --><router-link :to='{path:’testDemo’,query:{setid:123456}}'> <button>點(diǎn)擊跳轉(zhuǎn)1</button></router-link> <router-link :to='{name:’testDemo’,params:{setid:1111222}}'> <button>點(diǎn)擊跳轉(zhuǎn)3</button></router-link>

2:this.$router.push()

<template> <div id=’test’> <button @click=’goTo()’>點(diǎn)擊跳轉(zhuǎn)4</button> </div></template><script> export default{ name:’test’, methods:{ goTo(){ //直接跳轉(zhuǎn) this.$router.push(’/testDemo’); //帶參數(shù)跳轉(zhuǎn) this.$router.push({path:’/testDemo’,query:{setid:123456}}); this.$router.push({name:’testDemo’,params:{setid:111222}}); } } }</script>

params和query傳參數(shù)有什么不一樣??在地址欄中可以看到,params傳參數(shù)時(shí),地址欄中看不到參數(shù)的內(nèi)容,有點(diǎn)像ajax中的post傳參,query傳參數(shù)時(shí),地址欄中可以看到傳過(guò)來(lái)的參數(shù)信息,有點(diǎn)像ajax的個(gè)體傳參

如果單獨(dú)傳setId一個(gè)參數(shù)的時(shí)候,地址欄中的地址如下圖:

vue跳轉(zhuǎn)頁(yè)面的幾種方法(推薦)

第一種方式:path - query 傳參

vue跳轉(zhuǎn)頁(yè)面的幾種方法(推薦)

第二種方式:name - params傳參數(shù)

但是一般情況下,傳參數(shù)是傳遞一個(gè)對(duì)象,當(dāng)傳遞的是一個(gè)對(duì)象的時(shí)候,地址欄中的地址如下圖:

vue跳轉(zhuǎn)頁(yè)面的幾種方法(推薦)

第一種方式:path - query 傳參

vue跳轉(zhuǎn)頁(yè)面的幾種方法(推薦)

第二種方式:name - params傳參數(shù)

3:a標(biāo)簽可以跳轉(zhuǎn)么??可以跳轉(zhuǎn)外部鏈接,不能路由跳轉(zhuǎn)

<a ><button>點(diǎn)擊跳轉(zhuǎn)5</button></a>

接收方怎么接收參數(shù)??this.$route.query.serid和this.$route.params.setid,以下舉一個(gè)接收的例子

注意接收參數(shù)時(shí)是 $route 不是 $router

<template> <div> testDemo{{this.$route.query.setid}} </div></template>

知識(shí)點(diǎn)補(bǔ)充:vue三種不同方式實(shí)現(xiàn)頁(yè)面跳轉(zhuǎn)

Vue:router-lin

<router-link to='/'>[跳轉(zhuǎn)到主頁(yè)]</router-link> <router-link to='/login'>[登錄](méi)</router-link> <router-link to='/logout'>[登出]</router-link>

this.$router.push('/');

<button @click='goHome'>[跳轉(zhuǎn)到主頁(yè)]</button>export default { name: 'App', methods: { // 跳轉(zhuǎn)頁(yè)面方法 goHome() { this.$router.push('/'); },}

this.$router.go(1);

<button @click='upPage'>[上一頁(yè)]</button> <button @click='downPage'>[下一頁(yè)]</button> upPage() { // 后退一步記錄,等同于 history.back() this.$router.go(-1); }, downPage() { // 在瀏覽器記錄中前進(jìn)一步,等同于 history.forward() this.$router.go(1); }

代碼示例:

<template> <div id='app'> <img src='http://www.cgvv.com.cn/bcjs/assets/logo.png'> <router-view/> <router-link to='/'>[跳轉(zhuǎn)到主頁(yè)]</router-link> <router-link to='/login'>[登錄](méi)</router-link> <router-link to='/logout'>[登出]</router-link> <!-- javascript跳轉(zhuǎn)頁(yè)面 --> <button @click='goHome'>[跳轉(zhuǎn)到主頁(yè)]</button> <!-- 回到上一頁(yè) --> <button @click='upPage'>[上一頁(yè)]</button> <button @click='downPage'>[下一頁(yè)]</button> <!-- 回到下一頁(yè) --> </div></template> <script> export default { name: 'App', methods: { // 跳轉(zhuǎn)頁(yè)面方法 goHome() { this.$router.push('/'); }, upPage() { // 后退一步記錄,等同于 history.back() this.$router.go(-1); }, downPage() { // 在瀏覽器記錄中前進(jìn)一步,等同于 history.forward() this.$router.go(1); } } };</script>

總結(jié)

到此這篇關(guān)于vue不同方法跳轉(zhuǎn)頁(yè)面的幾種方法的文章就介紹到這了,更多相關(guān)vue 跳轉(zhuǎn)頁(yè)面內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Vue
相關(guān)文章:
主站蜘蛛池模板: 亚色网址 | 欧美一级毛片无遮挡 | 国产99视频精品免费视频7 | 亚洲精品tv久久久久 | 欧美整片在线观看 | 日产一区两区三区四区 | 国产在线精品观看 | 国产精品久久久久影视不卡 | 免费又黄又爽视频 | 香港三级日本三级妇人三级 | 日韩一区国产二区欧美三区 | 亚洲综合成人网 | 中文字幕在线精品 | 精品少妇一区二区三区视频 | 免费看欧美成人性色生活片 | 美女视频黄色免费 | 99热久久国产精品免费观看 | 大伊香蕉精品视频在线 | 精品毛片| 一级做性色a爱片久久片 | 福利网址在线 | 丁香久久 | 国产成人精品三级91在线影院 | 亚洲图片视频在线观看 | 特级毛片aaaa级毛片免费 | 国产欧美va欧美va香蕉在线 | 久久综合久美利坚合众国 | 成年女人毛片免费播放人 | 美女视频黄色的免费 | 欧美xxxxx色视频在线观看 | 97久草 | 亚洲一二区 | 亚洲国产日产韩国欧美综合 | 亚洲高清免费在线观看 | 在线观看国产精品日本不卡网 | 午夜性爽视频男人的天堂在线 | 深夜一级毛片 | 国产免费久久精品 | 91精品一区二区三区在线观看 | 国产精品久久福利网站 | 久久亚洲国产欧洲精品一 |