小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

Vue系列:通過(guò)vue

 ThinkTank_引擎 2017-02-13
使用vue-router 來(lái)實(shí)現(xiàn)webapp的頁(yè)面跳轉(zhuǎn),有時(shí)候需要傳遞參數(shù),做法如下:
參考文獻(xiàn):http://router./en/named.html 

主要有以下幾個(gè)步驟:
(1) 設(shè)置好路由配置
router.map({
  '/history/:deviceId/:dataId': {
    name: 'history', // give the route a name
    component: { ... }
  }
})
這里有2個(gè)關(guān)鍵點(diǎn):
    a)給該路由命名,也就是上文中的 name: 'history',
    b)在路徑中要使用在路徑中使用冒號(hào)開(kāi)頭的數(shù)字來(lái)接受參數(shù),也就是上文中的 :deviceId, :dataId;
 
(2)在v-link中傳遞參數(shù);
    <a v-link="{ name: 'history', params: { deviceId: 123, dataId:456 }}">history</a>
這里的123,456都可以改用變量。
比如該template所對(duì)應(yīng)的組件有2個(gè)變量定義如下:
data: function() {
    return {
      deviceId:123,
      dataId:456
        }
}    
此時(shí)上面那個(gè)v-link可以改寫(xiě)為:
    <a v-link="{ name: 'history', params: { deviceId: deviceId, dataId: dataId }}">history</a>
(3)在router的目標(biāo)組件上獲取入?yún)?/div>
    比如在router目標(biāo)組件的ready函數(shù)中可以這么使用。
    ready: function(){
        console.log('deviceid: ' + this.$route.params.deviceId);
        console.log('dataId: ' + this.$route.params.dataId);
    }


————完————





    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類似文章 更多