vue.js中打開(kāi)新頁(yè)面的方法

這篇文章主要介紹vue.js中打開(kāi)新頁(yè)面的方法,文中介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們一定要看完!

目前成都創(chuàng)新互聯(lián)已為成百上千家的企業(yè)提供了網(wǎng)站建設(shè)、域名、網(wǎng)絡(luò)空間、成都網(wǎng)站托管、企業(yè)網(wǎng)站設(shè)計(jì)、丹江口網(wǎng)站維護(hù)等服務(wù),公司將堅(jiān)持客戶(hù)導(dǎo)向、應(yīng)用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶(hù)和合作伙伴齊心協(xié)力一起成長(zhǎng),共同發(fā)展。

vue.js中打開(kāi)新頁(yè)面的方法:1、【router-link】跳轉(zhuǎn),代碼為【<router-link to="/detail/one">】;2、通過(guò)【this.$router.push】跳轉(zhuǎn)。

vue.js中打開(kāi)新頁(yè)面的方法:

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

   // 直接寫(xiě)上跳轉(zhuǎn)的地址
  <router-link to="/detail/one">
    <span class="spanfour" >link跳轉(zhuǎn)</span>
  </router-link>
  // 添加參數(shù)
  <router-link :to="{path:'/detail/two', query:{id:1,name:'vue'}}">
   </router-link>
  // 參數(shù)獲取
  id = this.$route.query.id
  // 新窗口打開(kāi)
  <router-link :to="{path:'/detail/three', query:{id:1,name:'vue'}}" target="_blank">
  </router-link>
```javascript

2.this.$router.push跳轉(zhuǎn)

```javascript
toDeail (e) {
   this.$router.push({path: "/detail", query: {id: e}})
 }
 // 參數(shù)獲取
 id = this.$route.query.id
 
 toDeail (e) {
   this.$router.push({name: "/detail", params: {id: e}})
 }
 // 注意地址需寫(xiě)在 name后面
 //參數(shù)獲取,params和query區(qū)別,query參數(shù)在地址欄顯示,params的參數(shù)不在地址欄顯示
 id = this.$route.params.id

3.this.$router.replace跳轉(zhuǎn)

//和push的區(qū)別,push有記錄一個(gè)history,replace沒(méi)有
 toDeail (e) {
   this.$router.replace({name: '/detail', params: {id: e}})
 }

4. resolve跳轉(zhuǎn)

  resolve頁(yè)面跳轉(zhuǎn)可用新頁(yè)面打開(kāi)
 2.1.0版本后,使用路由對(duì)象的resolve方法解析路由,可以得到location、router、href等目標(biāo)路由的信息。得到href就可以使用window.open開(kāi)新窗口了(這邊應(yīng)用:https://segmentfault.com/q/1010000009557100下的一個(gè)回答)
 toDeail (e) {
   const new = this.$router.resolve({name: '/detail', params: {id: e}})
   window.open(new.href,'_blank')
 }

以上是“vue.js中打開(kāi)新頁(yè)面的方法”這篇文章的所有內(nèi)容,感謝各位的閱讀!希望分享的內(nèi)容對(duì)大家有幫助,更多相關(guān)知識(shí),歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道!

網(wǎng)頁(yè)題目:vue.js中打開(kāi)新頁(yè)面的方法
本文地址:http://bm7419.com/article42/psschc.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供面包屑導(dǎo)航軟件開(kāi)發(fā)、建站公司、Google網(wǎng)站收錄、做網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀(guān)點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)

手機(jī)網(wǎng)站建設(shè)