laravel - 在 Google 联系人模板中的 Vuetify v-list 中定义路由器链接
问题描述
我是 Vuetify 的新手,我不知道如何在 vuetiy 提供的 Google 联系模板中的 v-list 中使用路由器链接。该列表与脚本标记内的数据属性绑定。如何添加路由器链接?
这是模板标签内的v-list 。
<v-list dense>
<template v-for="item in items">
<v-row
v-if="item.heading"
:key="item.heading"
align="center"
>
<v-col cols="6">
<v-subheader v-if="item.heading">
{{ item.heading }}
</v-subheader>
</v-col>
<v-col
cols="6"
class="text-center"
>
<a
href="#!"
class="body-2 black--text"
>EDIT</a>
</v-col>
</v-row>
<v-list-group
v-else-if="item.children"
:key="item.text"
v-model="item.model"
:prepend-icon="item.model ? item.icon : item['icon-alt']"
append-icon=""
>
<template v-slot:activator>
<v-list-item-content>
<v-list-item-title>
{{ item.text }}
</v-list-item-title>
</v-list-item-content>
</template>
<v-list-item
v-for="(child, i) in item.children"
:key="i"
link
>
<v-list-item-action v-if="child.icon">
<v-icon>{{ child.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
{{ child.text }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list-group>
<v-list-item
v-else
:key="item.text"
link
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
{{ item.text }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
</template>
</v-list>
这是脚本标签
data: () => ({
dialog: false,
drawer: null,
items: [
{ icon: 'mdi-contacts', text: 'Contacts' },
{ icon: 'mdi-history', text: 'Frequently contacted' },
{ icon: 'mdi-content-copy', text: 'Duplicates' },
{
icon: 'mdi-chevron-up',
'icon-alt': 'mdi-chevron-down',
text: 'Labels',
model: true,
children: [
{ icon: 'mdi-plus', text: 'Create label' },
],
},
{
icon: 'mdi-chevron-up',
'icon-alt': 'mdi-chevron-down',
text: 'More',
model: false,
children: [
{ text: 'Import' },
{ text: 'Export' },
{ text: 'Print' },
{ text: 'Undo changes' },
{ text: 'Other contacts' },
],
},
{ icon: 'mdi-settings', text: 'Settings' },
{ icon: 'mdi-message', text: 'Send feedback' },
{ icon: 'mdi-help-circle', text: 'Help' },
{ icon: 'mdi-cellphone-link', text: 'App downloads' },
{ icon: 'mdi-keyboard', text: 'Go to the old version' },
],
}),
请帮我。
解决方案
将路由路径添加到项目中的键,例如名为to
...
items: [
{ icon: 'mdi-contacts', text: 'Contacts', to: '/contacts' },
{ icon: 'mdi-history', text: 'Frequently contacted', to: '/route2' },
{ icon: 'mdi-content-copy', text: 'Duplicates', to: '/route3' },
...
]
然后,将该键值传递:to
给v-list-item
...
<v-list-item
v-else
:key="item.text"
:to="item.to?item.to:null"
>
<v-list-item-action>
<v-icon>{{ item.icon }}</v-icon>
</v-list-item-action>
<v-list-item-content>
<v-list-item-title>
{{ item.text }}
</v-list-item-title>
</v-list-item-content>
</v-list-item>
推荐阅读
- android - 如何在 xml android 中隐藏首选项?
- angular - PrimeNG 下拉菜单显示空选项
- c# - 从数据库C#中获取列表项时如何检查checkboxlist
- c++ - 用于输出流运算符的友元函数显示错误为不可访问
- javascript - 如何使 cytoscape-ctxmenu.js 适用于有条件的节点?
- php - 如何在 PHP 中接收和清除数组
- c# - SQLite - 加载时排除少数列值
- php - 我们如何使用 ajax 从 PHP 中的数据库中获取数据并显示在输入类型的值中?
- python - 从 pandas 数据框中删除行,其中的列包含字符串,其中单词的长度大于一定长度
- python - 用python写游戏程序,但是程序运行时左右键没反应