2016-09-06 71 views
3

我有一個VUE組件呈現導航列表,並通過導航列表,每個項目包括標題和鏈接:如何傳遞變量VUE路由器V-LINK

<template> 
    <ul> 
    <li v-for="item in list"><a v-link="{{ path: item.link }}"></a></li> 
    </ul> 
</template> 

<script> 
    export default { 
    props: ['list'] 
    } 
</script> 

我嘗試通過可變item.link至V-鏈接路徑,但失敗。

得到這個警告:

[Vue warn]: v-link="{{ path: item.link }}": attribute interpolation is not allowed in Vue.js directives and special attributes. 

我應該怎麼做,如果通過變量V-LINK路徑?

感謝您閱讀:)

回答

3

我用vue-router 2.x如下:

<router-link :to="{path: '/applications/' + currentApplicationId}" class="nav-link">Overview</router-link> 

更多的文檔可以發現here

相關問題