Skip to content

Instantly share code, notes, and snippets.

@evilnapsis
Created January 24, 2018 07:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save evilnapsis/456b388af41b14016cd7e70ad723610f to your computer and use it in GitHub Desktop.
Save evilnapsis/456b388af41b14016cd7e70ad723610f to your computer and use it in GitHub Desktop.
Llenar una Tabla con Vue.js, Php Y Mysql
<!-- 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