Skip to content

Adding constant declaration in template #6690

@tachibana-shin

Description

@tachibana-shin

What problem does this feature solve?

I'm developing an app that has v-for to repeat items. in v-for I need the return result of a function in two different positions. I can solve this problem by creating a new array, but it's very inconvenient and memory-consuming.

What does the proposed API look like?

The API that I imagined would look like this:

<template>
  <div v-for="name in users" :key="name" v-const:nameObj="name.split(' ')">
    First name: {{ nameObj[0] }} <br>
    Last name: {{ nameObj[1] }}
  </div>
</template>

It's like a directive system
v-const:[name]="[value]"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions