Demo entry 6864869

codigo

   

Submitted by anonymous on Aug 14, 2019 at 00:02
Language: HTML+Genshi. Code size: 3.2 kB.

<html>
<head>
<link rel="stylesheet" href="node_modules/bootstrap/dist/css/bootstrap.min.css">
    <script src="node_modules/vue/dist/vue.min.js"></script>
</head>
<body>
    <div id="aplicacion">        
        <h2>Introduzca numero  en literal entre 0 y 9</h2>
        <input type="text" class="form-control" v-model="numero1">
        <h2>Introduzca numero  en literal entre 0 y 9</h2>
        <input type="text" class="form-control" v-model="numero2">                        
        <button v-on:click="calculo" class="form-control btn btn-success">
            Sumar
        </button>
        <label>{{resultado}}</label>
    </div>    
    <script>
        new Vue({
            el:"#aplicacion",
            data:{
                numero1:0,
                numero2:0,
                resultado:0
            },
            methods: {
                calculo:function(){                    
                    var n1=this.literal(this.numero1);
                    var n2=this.literal(this.numero2);                    
                    var r=n1+n2;
                    this.resultado=this.numeral(r);                    
                },
                literal:function(x){
                    if(x=="cero"){
                        return 0;
                    }
                    if(x=="uno"){
                        return 1;
                    }
                    if(x=="dos"){
                        return 2;
                    }
                    if(x=="tres"){
                        return 3;
                    }
                    if(x=="cuatro"){
                        return 4;
                    }
                    if(x=="cinco"){
                        return 5;
                    }
                },
                numeral:function(x){
                    if(x==0){
                        return "cero";
                    }
                    if(x==1){
                        return "uno";
                    }
                    if(x==2){
                        return "dos";
                    }
                    if(x==3){
                        return "tres";
                    }
                    if(x==4){
                        return "cuatro";
                    }
                    if(x==5){
                        return "cinco";
                    }
                    if(x==6){
                        return "seis";
                    }
                    if(x==7){
                        return "siete";
                    }
                    if(x==8){
                        return "ocho";
                    }
                    if(x==9){
                        return "nueve";
                    }
                    if(x==10){
                        return "diez";
                    }
                }
            },
        })        
    </script>
<script src="node_modules/jquery/dist/jquery.min.js"></script>
<script src="node_modules/popper.js/dist/popper.min.js"></script>
<script src="node_modules/bootstrap/dist/js/bootstrap.min.js"></script>
</body>
</html>

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).