screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue array find element</h3> <input type="text" v-model="searchFruitInput" placeholder="Enter fruit name"> <button @click="searchFruit">Search Fruit</button> <p v-if="foundFruit">Fruit Found: {{ foundFruit }}</p> <p v-else>Fruit Not Found</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { fruits: ['apple', 'grapes', 'banana', 'orange'], searchFruitInput: '', foundFruit: '' }; }, methods: { searchFruit() { this.foundFruit = this.fruits.find(fruit => fruit === this.searchFruitInput); } } }); app.mount("#app"); </script> </body> </html>