Calcular IMC con Vue.js

<!DOCTYPE html> <html lang="es"> <head> <meta charset="utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <title>VueJS::Bootstrap</title> <!-- Vue JS --> <script src="js/vue.js"></script> <!-- jQuery --> <script src="js/jquery-3.3.1.min.js"></script> <!-- Bootstrap --> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous"> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> </head> <style type="text/css"> .class0 { background-color: #33FFAA; color: #2288CC; } </style> <body> <!-- jQuery first, then Popper.js, then Bootstrap JS <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js" integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q" crossorigin="anonymous"></script> <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js" integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl" crossorigin="anonymous"></script> --> <h1>Vue JS</h1> <div id="contenedor"> <div id="calculador"> <label>Calculadora de I.M.C.</label> <table style="width: 334px;"> <tbody> <tr> <td style="width: 59px;">Peso</td> <td style="width: 32px;"><input id="" type="number" v-model="newEntry.peso"/></td> <td style="width: 104px;"></td> </tr> <tr> <td style="width: 59px;">Talla</td> <td style="width: 32px;"><input type="number" v-model="newEntry.talla" /></td> <td style="width: 104px;"><button @click="calcular()" type="button" class="btn btn-primary">Obtener</button></td> </tr> </tbody> </table> <label @click="limpiar()">{{newEntry.resultado}}</label> </div> <script> var app = new Vue({ el: '#calculador', data: { newEntry: { peso: 0, talla: 0, resultado:'' }, },methods:{ calcular(){ if(this.newEntry.peso == 0){ this.newEntry.resultado='Falta peso'; }else if(this.newEntry.talla == 0){ this.newEntry.resultado='Falta talla'; }else{ var imc = this.newEntry.peso/(this.newEntry.talla*this.newEntry.talla); this.newEntry.resultado='El I.M.C. obtendo es: '+imc; } },limpiar(){ this.newEntry.resultado=''; this.newEntry.peso=0; this.newEntry.talla=0; } } }); </script> </div> </body> </html>
Cálculo de índice de masa corporal (imc) usando vue.js.

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.