问题
How to use vue-router with using that predefined template:
https://vuetifyjs.com/examples/layouts/google-contacts
I have added a link in my items object
items:
[{ icon: 'dashboard' text: 'Home', link: '/'},
{ icon: 'dashboard' text: 'Account', link: '/account'},
I am confused where to put the router-link component.
回答1:
v-list-tile
, v-btn
, and v-card
all extend router-link
, so you can use any of the router-link
attributes directly on those components instead.
In your case you can just use <v-list-tile :to="item.link">
回答2:
I had the same problem, and I solved it like this:
<v-list-item v-else :key="item.text" link>
<!-- to -->
<v-list-item v-else :key="item.text" :to="item.link" link>
<v-list-item v-for="(child, i) in item.children" :key="i" link>
<!-- to -->
<v-list-item v-for="(child, i) in item.children" :key="i" :to="child.link" link>
JS
{ icon: "mdi-history", text: "Recientes", link: "/" },
Don't forget to put <router-view />
in the container.
<v-content>
<v-container class="fill-height" fluid>
<router-view />
</v-container>
</v-content>
来源:https://stackoverflow.com/questions/47586022/router-link-with-vue-and-vuetify-confusion