Remove Comma In The Last Element In Javascript Vuejs
I want to remove comma in the last element in Vue. But I dont know how to do that because the index of the last element is unknown. )}}
</td>
I'd be tempted to move it to a computed though - keeps markup clean
<td v-if="category.sub_category.length > 0">
{{subcats}}
</td>
computed: {
subcats() {
returnthis.category.sub_category.map(({subcategory_name}) => subcategory_name).join(', ');
}
}
Solution 2:
elements.join(',')
You don't need to create a function for this just use it inside the Vue tag like this
{{elements.join(',')}}
Please check in image. I posted answer after checking.
Post a Comment for "Remove Comma In The Last Element In Javascript Vuejs"