【发布时间】:2020-04-06 15:15:52
【问题描述】:
我想将我的props.items 传递给之后在 Firebase 中更改/删除它的值的方法。我是通过@click 执行此操作的,但 Vue 不允许在方法声明中使用props.item.id。我错过了什么?
<v-data-table
:headers="headers"
:items="products"
:sort-by="['description']"
:search="search"
:items-per-page="15"
class="elevation-1">
<template slot="items" slot-scope="props" >
<td><v-chip small>{{props.item.id}}</v-chip></td>
<td>{{props.item.name}}</td>
<td>{{props.item.description}}</td>
<td>{{props.item.price}}</td>
<td>{{props.item.ingredients}}</td>
<td>
<v-chip small>{{props.item.type}}</v-chip>
</td>
<td><v-btn @click="onDelete(props.item.id)" class="material-icons medium">delete</v-btn></td>
</template>
</v-data-table>
以及脚本摘录:
export default {
methods: {
onDelete(props.item.id) {
// ...
}
}
}
【问题讨论】:
-
onDelete(props.item.id) {}不是有效的方法声明,因为参数名称不能是props.item.id。 -
我认为您已经在 onclick 中以
props.item.id传递,因此您的onDelete上的参数将仅为id:>
标签: javascript firebase vue.js vuetify.js vuefire