<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>find the first position of word 'Vue' </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 :'With Vue tutorials becoming increasingly popular, its important to learn how to use the framework effectively ',
results:''
}
},
methods:{
myFunction(){
this.results = this.text.search('Vue');
},
}
}).mount('#app')
</script>
</body>
</head>
</html>