screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script type="importmap"> { "imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" } } </script> </head> <body> <div id="app"> <p>To find the first element that is an odd number in Vue.js</p> <p>Numbers: {{ numbers }}</p> <button @click="findOddNumberIndex">Check Odd Number</button> <p>Index of First Odd Number: {{ result }}</p> </div> <script type="module"> import { createApp } from 'vue'; createApp({ data() { return { numbers: [32, 51, 83, 96, 54, 707], result: '' }; }, methods: { findOddNumberIndex() { this.result = this.numbers.findIndex(number => number % 2 === 1); } } }).mount('#app'); </script> </body> </html>