Guest User

Untitled

a guest
Feb 4th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.53 KB | None | 0 0
  1. export default {
  2. data(){
  3. return {
  4. user: {
  5. firstname: '',
  6. lastname: '',
  7. email: '',
  8. password: ''
  9. },
  10. errors: [],
  11. users: [],
  12. update_user: {}
  13. }
  14. },
  15. mounted(){
  16. this.readUsers();
  17. },
  18. methods: {
  19. createUser(){
  20. axios.post('user', {
  21. firstname: this.user.firstname,
  22. lastname: this.user.lastname,
  23. email: this.user.email,
  24. password: this.user.password
  25. }).then(response => {
  26. this.reset();
  27. if (response.data.message == "Error"){
  28. this.errors.push("L'utilisateur que vous tentez d'ajouter existe déjà!")
  29. }else{
  30. this.users.push(response.data.user);
  31. }
  32. })
  33. },
  34. }
  35. }
  36.  
  37. <table class="table table-bordered table-striped table-responsive" v-if="users.length > 0">
  38. <tbody>
  39. <tr>
  40. <th>#</th>
  41. <th>Nom</th>
  42. <th>Prénom</th>
  43. <th>Adresse e-mail</th>
  44. <th>Action</th>
  45. </tr>
  46. <tr v-for="(user, index) in users">
  47. <td>{{ user.id }}</td>
  48. <td>{{ user.lastname }}</td>
  49. <td>{{ user.firstname }}</td>
  50. <td>{{ user.email }}</td>
  51. <td>
  52. <button @click="initUpdate(index)" class="btn btn-success btn-xs">Éditer</button>
  53. <button @click="deleteUser(index)" class="btn btn-danger btn-xs">Supprimer</button>
  54. </td>
  55. </tr>
  56. </tbody>
  57. </table>
Add Comment
Please, Sign In to add comment