Tutorialsplane

Vue.js string search


JavaScript search() method is used to search a value in a string. Here in this tutorial, we are going to explain how you can use this method to search a value in string in vuejs. You can use our online editor to edit and run the code online.


Vue.js string search Vuejs JavaScript Example

Here is an example of search method in vuejs –

Example:

<div id="app">	
	<p>{{myStr}}</p>
	<p>{{result}}</p>
	<button>Click Me</button>
</div>
  

Try it »

If value is found in string then it will return the position of value else it will return -1.

Output of above example-