Categories
How to remove comma at the end of v-for?
It seems like a simple task, but what did I think. The code
<span v-for="name in names" :key="name">{{name}}, </span>
Answer the question
In order to leave comments, you need to log in
Add a comma depending on the index of the current element:
<span v-for="(n, i) in names">{{ n }}{{ i < n.length - 1 ? ', ' : '' }}</span>
<span v-text="names.join(', ')"><span>
Didn't find what you were looking for?
Ask a Question
731 491 924 answers to any question