亚洲最大看欧美片,亚洲图揄拍自拍另类图片,欧美精品v国产精品v呦,日本在线精品视频免费

  • 站長(zhǎng)資訊網(wǎng)
    最全最豐富的資訊網(wǎng)站

    vuejs中跳轉(zhuǎn)如何傳參

    vue跳轉(zhuǎn)傳參的方法:1、通過(guò)router-link標(biāo)簽的params或query屬性進(jìn)行跳轉(zhuǎn)傳參;2、通過(guò)“this.$router.push({name:'路由命名',params:{參數(shù)名:參數(shù)值..}})”語(yǔ)句進(jìn)行跳轉(zhuǎn)傳參。

    vuejs中跳轉(zhuǎn)如何傳參

    本教程操作環(huán)境:windows7系統(tǒng)、vue2.9.6版,DELL G3電腦。

    首先創(chuàng)建readDetail.vue 且在index.js中注冊(cè)路由。

    傳遞頁(yè)面方式:

    1.通過(guò)router-link進(jìn)行跳轉(zhuǎn)

    <router-link        :to="{           path: 'yourPath',              params: {                key: 'value', // orderNum : this.searchData.orderNo         },           query: {              key: 'value', // orderNum : this.searchData.orderNo         }       }">       <button type="button">跳轉(zhuǎn)</button>  </router-link>    1. path -> 是要跳轉(zhuǎn)的路由路徑,也可以是路由文件里面配置的 name 值,兩者都可以進(jìn)行路由導(dǎo)航    2. params -> 是要傳送的參數(shù),參數(shù)可以直接key:value形式傳遞    3. query -> 是通過(guò) url 來(lái)傳遞參數(shù)的同樣是key:value形式傳遞

    2. $router方式跳轉(zhuǎn)

    this.$router.push({name:'路由命名',params:{參數(shù)名:參數(shù)值,參數(shù)名:參數(shù)值}})

     this.$router.push({               path: 'yourPath',                name: '要跳轉(zhuǎn)的路徑的 name,在 router 文件夾下的 index.js 文件內(nèi)找',               params: {                    key: 'key',                    msgKey: this.msg               }               /*query: {                   key: 'key',                    msgKey: this.msg               }*/           })

    接受方式

    • this.$route.params.參數(shù)名

    • this.$route.query.參數(shù)名

    實(shí)驗(yàn)(包含兩種方式):

    傳遞頁(yè):

     <router-link :to="{ name: 'readDetail', params: { msgKeyOne: 'jump test.' }}">                 <button type="button">跳轉(zhuǎn)</button>               </router-link> <button @click="sendParams">傳遞</button> ----------------------------------------------------------------------------------------- export default {     name: 'reads',     data () {       return {         msg: 'msg test.'       }     },

    接收頁(yè):

    <p class="container">     <p style="color:red;">Num:{{ myIndex }}</p>     <p>{{ msg }}</p>   </p> ----------------------------------------------------------- data () {       return {         msg: '',         // 保存?zhèn)鬟f過(guò)來(lái)的index         myIndex: ''       } ----------------------------------------------------------- mounted: function () {       this.msg = this.$route.params.msgKeyOne       this.myIndex = this.$route.params.msgKey       console.log(this.myIndex)     }

    實(shí)驗(yàn)結(jié)果:

    vuejs中跳轉(zhuǎn)如何傳參

    贊(0)
    分享到: 更多 (0)
    網(wǎng)站地圖   滬ICP備18035694號(hào)-2    滬公網(wǎng)安備31011702889846號(hào)