ccc

vue.js: concatenar cadenas

<!doctype html>
<html>
<head>
  <title>Prueba Vue</title>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
  <div id="appLSG">
    <p>Nombre:<input type="text" v-model="nombre"></p>
    <p>Apellidos:<input type="text" v-model="apellidos"></p>
    <p>Nombre completo: {{nombreCompleto}}</p>

  </div>

  <script src="https://cdn.jsdelivr.net/npm/vue"></script>
  <script>
   var app=new Vue({
       el: '#appLSG',
       data: {
         nombre: '',
         apellidos: ''
       },
       computed:{
        nombreCompleto: function () {
           return this.nombre + ' ' + this.apellidos;
        }

       }
   })
  </script>
</body>
</html>

No hay comentarios:

Publicar un comentario