New Jan 3, 2025

Is `key` still necessary on `v-for` when nested in `v-once`?

Libraries, Frameworks, etc. All from Newest questions tagged vue.js - Stack Overflow View Is `key` still necessary on `v-for` when nested in `v-once`? on stackoverflow.com

I'm using Vue 3. And I have a piece of code like this

<div v-once>
  <div v-for="hour in [...Array(25)].map((_, i) => i)">{{ `0${hour}:00`.slice(-5) }}</div>
</div>

I'm getting eslint (with eslint-plugin-vue) error:

Elements in iteration expect to have 'v-bind:key' directives. (vue/require-v-for-key)

I wonder if it is a false positive, as I have no idea why we need key here.

Scroll to top