Created
January 24, 2018 07:03
-
-
Save evilnapsis/456b388af41b14016cd7e70ad723610f to your computer and use it in GitHub Desktop.
Llenar una Tabla con Vue.js, Php Y Mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- Powered by Evilnapsis http://evilnapsis.com --> | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Ejemplo Vue.js</title> | |
<script type="text/javascript" src="vue.min.js"></script> | |
</head> | |
<body> | |
<h1>Ejemplo de Listar Datos con Vue.js</h1> | |
<div id="app" class="container"> | |
<table border="1"> | |
<thead> | |
<th>Id</th> | |
<th>Nombre</th> | |
<th>Apellido</th> | |
<th>Telefono</th> | |
</thead> | |
<tr v-for="data in all_data "> | |
<td>{{data.id}}</td> | |
<td>{{data.name}}</td> | |
<td>{{data.lastname}}</td> | |
<td>{{data.phone}}</td> | |
</tr> | |
</ul> | |
</div> | |
<script> | |
var app = new Vue({ | |
el: "#app", | |
data: { | |
all_data:[] | |
}, | |
created: function(){ | |
console.log("Iniciando ..."); | |
this.get_contacts(); | |
}, | |
methods:{ | |
get_contacts: function(){ | |
fetch("./contactos.php") | |
.then(response=>response.json()) | |
.then(json=>{this.all_data=json.contactos}) | |
} | |
} | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment