Cristian
Cristian

Reputation: 167

Accessing value of array inside of array in vuejs

I am currently learning Vue3. I am trying to access the values of the array inside an array to make a nice table. Then, those values will be separated by a comma.

Here is the link: https://stackblitz.com/edit/vue-chdcrt?

Expected output:

name | email | socialMedia

Ram | [email protected] | Weibo, Linkedln

Upvotes: 3

Views: 463

Answers (3)

Ameer
Ameer

Reputation: 2000

You can just use array.join(character to split with) to convert the array of social medias into a string list. In this case it would be

<td>{{ info.socialMedia.join(', ') }}</td>

Project link

Upvotes: 1

Andrii Antoniuk
Andrii Antoniuk

Reputation: 75

to complete your goals you should use Array.join() method. Also, I strongly recommend you use MDN when looking for built-in methods.

In your case it will be look like:
<td>{{ info.socialMedia.join(', ') }}</td>

Upvotes: 1

DecPK
DecPK

Reputation: 25416

You can use join here to join array of strings as:

live DEMO

<td>{{ info.socialMedia.join(", ") }}</td>

Upvotes: 0

Related Questions