0

I want to split the values from the String and add it to an array where I use it to display values in a drop down manner in Vuejs

String val1 = "abc,123,676,uuu". 

Once iterated

          <li v-for = "val in valList" :key="val.index"> {{val}}</li>

     abc
     123
     676
     uuu
1
  • straightforward .split(",") right? Commented Nov 18, 2020 at 12:19

1 Answer 1

1
var names = 'Harry,John,Clark,Peter,Rohn,Alice';
var nameArr = names.split(',');
console.log(nameArr);

reference

Sign up to request clarification or add additional context in comments.

1 Comment

this.list.forEach((val)=>{ if (val.name !==null} { this.mainList.push(val.name.split(',')}}). I have name which may contain comma separated or single value.I need to push it to mainList. But I see the values like [abc,123,676,uuu] and [777] displaying under drop down

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.