Advertisement
lamhotsimamora

vue

May 4th, 2024
781
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  var app=  new Vue({
  2.         el : "#app",
  3.         data : {
  4.             books: null
  5.         },
  6.         methods: {
  7.             loadImage: function(image){
  8.               return 'storage/'+image
  9.             },
  10.             updateData : function(data){
  11.               edit.name = data.name;
  12.               edit.cover = data.cover;
  13.               edit.price = data.price;
  14.               edit.id = data.id;
  15.             },
  16.             loadData: async function(){
  17.              
  18.                 try {
  19.                     const response = await axios.get('/books');
  20.                     this.books = response.data;
  21.                 } catch (error) {
  22.                      console.error(error);
  23.                 }
  24.             },
  25.             deleteData: function(id){
  26.                 axios.post('/book-delete', {
  27.                     id: id,
  28.                     _token : _TOKEN_
  29.                 })
  30.                 .then(function (response) {
  31.                     alert("success delete data")
  32.                     window.location.href="."
  33.                 })
  34.                 .catch(function (error) {
  35.                     console.log(error);
  36.                 });
  37.             }
  38.         },
  39.         mounted() {
  40.             this.loadData();
  41.         },
  42.     })
  43.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement