我在v-for中使用index,试图在一个函数中使用它来从数组中删除该项。索引已定义,但从未使用作为来自linter的错误弹出。
我不确定放置索引的正确方式,因为这是教程中说明的方式。
<template>
<div class="row">
<app-quote v-for="(quote,index) in quotes" :key="quote.id" @click.native="deleteQuote">{{ quote }}</app-quote>
</div>
</template>
<script>
import Quote from './Quote.vue';
export default {
props: ['quotes'],
components: {
appQuote: Quote
},
methods: {
deleteQuote(index) {
this.$emit('quoteDeleted', index);
}
},
}
</script>
https://stackoverflow.com/questions/55737604
复制相似问题