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 checkbox array of objects</h3> <h2>Select Items</h2> <div v-for="(item, index) in items" :key="index"> <label> <input type="checkbox" :value="item" v-model="selectedItems"> {{ item.name }} </label> </div> <h2>Selected Items</h2> {{selectedItems}} </div> <script type="module"> const app = Vue.createApp({ data() { return { items: [ { id: 1, name: 'Item 1' }, { id: 2, name: 'Item 2' }, { id: 3, name: 'Item 3' }, { id: 4, name: 'Item 4' }, { id: 5, name: 'Item 5' }, ], selectedItems: [], }; }, }); app.mount('#app'); </script> <style> #app { font-family: Arial, sans-serif; width: 80%; margin: 0 auto; padding: 20px; background-color: #f5f5f5; } h2 { font-size: 24px; margin-bottom: 10px; } label { display: block; margin-bottom: 10px; } input[type="checkbox"] { margin-right: 10px; vertical-align: middle; } .selected { font-weight: bold; } </style> </body> </html>