screen_rotation
Copied to Clipboard
<html> <head> <script type="importmap"> { "imports": { "vue": "https://unpkg.com/vue@3/dist/vue.esm-browser.js" } } </script> <body> <div id="app"> <h2>Vue js Math.abs() Method </h2> <p>convert a negative number to a positive number in Vue.js</p> <button @click='myFunction'>click me</button> <p>{{negNumber}}</p> <p>Positive Number: {{posNumber}}</p> </div> <script type="module"> import { createApp } from 'vue' createApp({ data() { return{ negNumber:[-34,-21,-63,-28], posNumber:[] } }, methods:{ myFunction(){ for(var i=0; i <this.negNumber.length;i++){ this.posNumber.push(Math.abs(this.negNumber[i])) } } } }).mount('#app') </script> </body> </head> </html>