Category Archives: Vue.Js Blog

Vue.js Array Filter


This method is used to create an array which is filled with elements that pass the test based on function passed. Here in this tutorial, we are going to explain how you can use this function in vuejs. You can use our online editor to edit and run the code online.


Vue.js Array Filter Method Example

You can use array filter function in vue.js simply as below-

Example:

item 1 = {{ item1 }}

item 2 = {{ item2 }}

Try it »

The above example will return the array based on filter function. For example we have created checkNum function to check whether the array value is greater than 9. It will return an array with values greater than 9.

Output of above example-

Vue.js array filter example

Vue.Js Array Concat


We can join two or more arrays using JavaScript concat method in Vue.js. Here in this tutorial, we are going to explain how you can use this method in VueJs to join two or more arrays.


Vue.Js Array Concat Method Example

Here is an example of concat method in Vue.js-

Concat Function Example:

item 1 = {{ item1 }}

item 2 = {{ item2 }}

Concat = {{ item3 }}

Try it »

Concat function joins two or more arrays and returns the final array.

Output of above example-

Vue.js Array concat

Vue.Js String Substr


This method is used to extract the characters from a string beginning form specified character to the number of characters. You can use this function same as native JavaScript. You can also use our online editor to edit and run the code online.


Vue.Js String Substr Method Example

You can use substr function in vue.js simply as below-

Example:

{{ substr }}

Try it »

Output of above example-

Vue.js string substr

Vue.js String Split


JavaScript split function basically converts a string into array of substring. We can use the native JavaScript split function to convert a string into array of substring. Here in this article we are going to explain how you can use this method in Vuejs. You can also use online editor to edit and run the code online.


Vue.js String Split Method Example

Here is an example to use split function in vue.js-

Example:

 


{{ splitedStr }}

Try it »

The above example will split the string at blank space (” “), you can also define other parameters as well such as split string at (-).

Output of above example-

Vue.js string split JavaScript Example

Vue.js String Slice


This method is basically used to extract a part of string from a string. We can use the native slice function to extract a part of string from a string. Here in this tutorial, we are going to explain how you can use the string slice method in vuejs. You can also use our online editor to edit and run the code online.


Vue.js String Slice Method Example

You can use slice method simply as below-

Example:

 


{{ message }}

Try it »

If you run the above example it will produce output something like this-

Vue.js String Slice Method Example

Vue.js String Replace


We can use native javascript string replace function to replace a value in string. Here in this tutorial, we are going to explain how you can use replace method in VueJS. You can also use our online editor to edit and run the code online.


Vue.js String Replace Example

Here is an example of replace function in vue.js. –

Example:

 


{{ message }}

Try it »

On the same way you can use this function to replace a value or pattern.

Output of above example-

Vue.Js String Replace function example

Vue.Js get element by id


We use $refs to access the DOM elements in vuejs. We can use $refs property to access the element by id. You can add the $refs attribute to the any element to vue instance. Here in this article, we are going to explain how to use the $refs property to access the elements.


Get Element By Id Or Refs Example

You can access any element using $refs in vue.js. Here is simple example.

Example:

 


{{ message }}

Try it »

On the same way you can access any element using ref same as id.

Output of above example-

Vue.js get element by id example

Vue.Js String Match


We can use native JavaScript string match function to search a string against regular expression. Here in this tutorial, we are going to explain how you can use string match method in VueJs. You can also use our online editor to edit and run the code online.


String Match Method Vue.Js JavaScript Example

You can use JavaScript match() method simply as below-

Example:

 


{{result}}

Try it »

The above example will return the array of objects against the match.

Output of above example-

Vue.Js String Match Javascript Example

Vue.js string indexOf


String indexOf Method– We can use native JavaScript indexOf to get the position of first occurrence of specified value. Here in this tutorial, we are going to explain how you can use this method to find the position of string/character in vuejs.


String indexOf Method In Vue.JS Example

You can get the position of a specified value in a string simply as below-

Example:

 


{{result}}

Try it »

  • indexOf– This method returns the position of first occurrence of specified value.
  • It return -1 if the value is not found in string.

If you run the above example it will produce the output something like this-

Vue.js string indexOf JavaScript Example