screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Adding Items to an Array with an Input Element in Vue.js</h3> <input v-model="newItem" @keyup.enter="addItem" /> <ul> <li v-for="item in items" :key="item">{{ item }}</li> </ul> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { newItem: '', items: [] } }, methods: { addItem() { this.items.push(this.newItem) this.newItem = '' } } }); </script> </body> </html>