Vue JS Convert String to Array | Vue JS Split String Example

Vue JS Convert String to Array | Vue JS Split String Example

In this post we will give you information about Vue JS Convert String to Array | Vue JS Split String Example. Hear we will give you detail about Vue JS Convert String to Array | Vue JS Split String ExampleAnd how to use it also give you demo for it if it is necessary.

Today i will show you how to convert string to array using split() in vue js. i will give simple example of split string with space, comma, semicolon etc in vuejs.

If you worked with javascript then you know split() and how it use. The split() method is used to split the string into an array of the substring and returns a new collection array. you can see bellow following syntax:

myArray.split(separator);

bellow i gave you simple example of convert string into an array with space. i will also show you output of array, so you can understand how it works.

Example:

<!DOCTYPE html>

<html>

<head>

<title>Vue JS Convert String to Array | Vue JS Split String Example - ItSolutionStuff.com</title>

<script src="https://cdn.jsdelivr.net/npm/vue"></script>

</head>

<body>

<div id="app">

<p>String : {{ myString }}</p>

<p>Array : {{myResult}}</p>

<button @click="clickFunction()">Click Me</button>

</div>

<script type="text/javascript">

var app = new Vue({

el: '#app',

data: {

myString: "This is ItSolutionStuff.com" ,

myResult: ''

},

methods:{

clickFunction: function () {

this.myResult = this.myString.split(" ");

}

}

})

</script>

</body>

</html>

Output:

Also see:Vue JS Get Array Length Or Object Length Example

String : This is ItSolutionStuff.com

Array : [ "This", "is", "ItSolutionStuff.com" ]

I hope it can help you…

Hope this code and post will helped you for implement Vue JS Convert String to Array | Vue JS Split String Example. if you need any help or any feedback give it in comment section or you have good idea about this post you can give it comment section. Your comment will help us for help you more and improve us. we will give you this type of more interesting post in featured also so, For more interesting post and code Keep reading our blogs

For More Info See :: laravel And github

Leave a Comment

Your email address will not be published. Required fields are marked *

4  +  3  =  

We're accepting well-written guest posts and this is a great opportunity to collaborate : Contact US