screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <h3>Vue js Convert Multiple Object into Array </h3> <div id='app'> <ul> <li v-for="(item, index) in combinedArray" :key="index">{{ item[0] }}: {{ item[1] }}</li> </ul> </div> <script type="module"> const app = new Vue({ el: "#app", data: { obj1: { name: 'John', age: 30, role: 'frontend developer' }, obj2: { name: 'Jane', age: 25, role: 'backend developer' }, combinedArray: [] }, mounted() { // Convert objects to arrays using Object.entries() const arr1 = Object.entries(this.obj1); const arr2 = Object.entries(this.obj2); // Combine arrays into a single array this.combinedArray = [...arr1, ...arr2]; } }); </script> </body> </html>