我有<router-link to = "/ endreco / test">
,但我需要在vue-material标签上执行相同的操作,如下所示:<md-tab md- icon = "books">
..更改我的路线,与{{1}相同}
我该怎么办?
我正在使用vue.js,vue-router用vue-material控制路由和样式
答案 0 :(得分:3)
您可以添加@click.native
处理程序以手动推送到路线(由于.native
modifier没有click
事件,因此需要md-tab
component:
<md-tab @click.native="$router.push('/endreco/test')">
Here's the documentation on Programmatic Navigation with Vue Router.
答案 1 :(得分:1)
查看我的代码我已经实现了一个遍历路由器的方法来查看提到的组件名称的路由,你可以轻松搞定!
<template>
<div>
<div class="mdl-grid">
<div class="mdl-cell mdl-cell--3-col mdl-cell mdl-cell--1-col-tablet mdl-cell--hide-phone"></div>
<div class="mdl-cell mdl-cell--6-col mdl-cell--4-col-phone">
<div class="image-card" v-for="picture in this.pictures" @click="displaydetails(picture.id) ">
<div class="image-card__picture">
<img :src="picture.url" />
</div>
<div class="image-card__comment mdl-card__actions">
<span>{{ picture.comment }}</span>
</div>
</div>
</div>
</div>
<router-link class="add-picture-button mdl-button mdl-js-button mdl-button--fab mdl-button--colored" to="/postview">
<i class="material-icons">add</i>
</router-link>
</div>
</template>
<script>
import data from '../data'
export default {
data() {
return{
'pictures' : data.pictures
}
},
methods :{
displaydetails (id){
this.$router.push({name:'detailview', params:{id:id}});
console.log("helo");
}
}
}
</script>
希望能从中获得足够的资源!