router-link with vue and vuetify confusion

痴心易碎 提交于 2020-04-08 00:01:26

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!