Home > database >  Accessing value of array inside of array in vuejs
Accessing value of array inside of array in vuejs

Time:11-11

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

CodePudding user response:

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

CodePudding user response:

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

live DEMO

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

CodePudding user response:

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>

  • Related