<html>
<head>
<script type="importmap">
{
"imports": {
"vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js"
}
}
</script>
<body>
<div id="app">
<h2>Vue js String Search Method </h2>
<p>Search first index of character with given text</p>
<button @click="myFunction">click me</button>
<p>Text: {{text}}</p>
<p>First Index :{{results}}</p>
</div>
<script type="module">
import { createApp } from 'vue'
createApp({
data()
{
return{
text :'Learn Vue Js tutorials: learn vue tutorials the in easy way here. ',
searchText:'Vue',
results:''
}
},
methods:{
myFunction(){
this.results = this.text.search(this.searchText);
},
}
}).mount('#app')
</script>
</body>
</head>
</html>