screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.22/dist/vue.global.js"></script> </head> <body> <div id="app"> <h3>Vue Js Remove Leading Zero from Array</h3> <p>Original Array: {{ originalArray }}</p> <p>Array with leading zeros removed: {{ nonZeroArray }}</p> </div> <script type="module"> const app = Vue.createApp({ data() { return { originalArray: [0, 0, 0, 4, 3, 4, 0, 0, 9, 1], nonZeroArray: [] } }, mounted() { let array = [...this.originalArray]; // create a copy of the original array to work with while (array[0] === 0) { array.shift(); } this.nonZeroArray = array; // set the nonZeroArray data property to the modified array } }) app.mount('#app') </script> <style scoped> #app { font-family: Arial, sans-serif; padding: 20px; } h3 { font-size: 24px; color: #333; } p { font-size: 18px; color: #666; } </style> </body> </html>