screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html lang="en"> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>Vue Js Multiple Two Array of Element</h3> <div class="custom-class"> <h2>Array 1:</h2> {{array1}} </div> <div class="custom-class"> <h2>Array 2:</h2> {{array2}} </div> <div class="custom-class"> <h2>Result:</h2> {{multipliedArray}} </div> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { array1: [1, 2, 3, 4], array2: [2, 3, 4, 5], }; }, computed: { multipliedArray() { if (this.array1.length !== this.array2.length) { console.error('Arrays must have the same length for element-wise multiplication.'); return []; } return this.array1.map((value, index) => value * this.array2[index]); }, }, }) </script> <style scoped> #app { margin: 0 auto; width: 500px; text-align: center; box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.12), 0 2px 4px 0 rgba(0, 0, 0, 0.24); padding: 20px; } </style> </body> </html>