Simple Vue js CRUD Example Tutorial From Scratch

Today, We want to share with you Simple Vue js CRUD Example Tutorial From Scratch.In this post we will show you Basic CRUD Operations Using Vue.js Example, hear for VueJS CRUD Operations in Laravel we will give you demo and example for implement.In this post, we will learn about Creating a simple CRUD application with Laravel 5 and Vue.js with an example.

Simple Vue js CRUD Example Tutorial From Scratch

There are the Following The simple About Simple Vue js CRUD Example Tutorial From Scratch Full Information With Example and source code.

As I will cover this Post with live Working example to develop Vue.js CRUD application, so the some major files and Directory structures for this example is following below.

  • index.html

HTML interface View

index.html

This is where I will make a simple HTML form and PHP server side source code for our web application. To make the forms simply all souce code copy and write it into your any text editor Like Notepad++, then save file it as index.html.




    
    Simple Vue js CRUD Example Tutorial From Scratch - pakainfo.com
    
    


VueJs Source Code

index.js

var billreceipts = [
  {id: 1, name: 'Vuejs pakainfo.com', detail: 'Provide Vuejs Information.', rate: 1200},
  {id: 2, name: 'Angular 6 pakainfo.com', detail: 'Provide Angular 6 Information.', rate: 1200},
  {id: 3, name: 'Laravel 5.6 pakainfo.com', detail: 'Provide Laravel 5.6 Information.', rate: 1200}
];
function findbillreceipt (billreceiptId) {
  return billreceipts[findbillreceiptKey(billreceiptId)];
};
function findbillreceiptKey (billreceiptId) {
  for (var key = 0; key < billreceipts.length; key++) {
    if (billreceipts[key].id == billreceiptId) {
      return key;
    }
  }
};
var List = Vue.extend({
  template: '#billreceipt-list',
  data: function () {
    return {billreceipts: billreceipts, searchKey: ''};
  },
  computed : {
    filteredbillreceipts: function () {
    var self = this;
    console.log()
    return self.billreceipts.filter(function (billreceipt) {
      return billreceipt.name.indexOf(self.searchKey) !== -1
    })
  }
}
});
var billreceipt = Vue.extend({
  template: '#billreceipt',
  data: function () {
    return {billreceipt: findbillreceipt(this.$route.params.billreceipt_id)};
  }
});
var billreceiptEdit = Vue.extend({
  template: '#billreceipt-edit',
  data: function () {
    return {billreceipt: findbillreceipt(this.$route.params.billreceipt_id)};
  },
  methods: {
    updatebillreceipt: function () {
      var billreceipt = this.billreceipt;
      billreceipts[findbillreceiptKey(billreceipt.id)] = {
        id: billreceipt.id,
        name: billreceipt.name,
        detail: billreceipt.detail,
        rate: billreceipt.rate
      };
      router.push('/');
    }
  }
});
var billreceiptDelete = Vue.extend({
  template: '#billreceipt-delete',
  data: function () {
    return {billreceipt: findbillreceipt(this.$route.params.billreceipt_id)};
  },
  methods: {
    deletebillreceipt: function () {
      billreceipts.splice(findbillreceiptKey(this.$route.params.billreceipt_id), 1);
      router.push('/');
    }
  }
});
var Addbillreceipt = Vue.extend({
  template: '#billreceipt-add',
  data: function () {
    return {billreceipt: {name: '', detail: '', rate: ''}
    }
  },
  methods: {
    createbillreceipt: function() {
      var billreceipt = this.billreceipt;
      billreceipts.push({
        id: Math.random().toString().split('.')[1],
        name: billreceipt.name,
        detail: billreceipt.detail,
        rate: billreceipt.rate
      });
      router.push('/');
    }
  }
});
var router = new VueRouter({
  routes: [{path: '/', component: List},
    {path: '/billreceipt/:billreceipt_id', component: billreceipt, name: 'billreceipt'},
    {path: '/billreceipt-add', component: Addbillreceipt},
    {path: '/billreceipt/:billreceipt_id/edit', component: billreceiptEdit, name: 'billreceipt-edit'},
  {path:   '/billreceipt/:billreceipt_id/delete', component: billreceiptDelete, name: 'billreceipt-delete'}
]});
new Vue({
  el: '#app',
  router: router,
  template: ''
});

Simple Vue js CRUD Example Tutorial From Scratch - Output

Simple Vue js CRUD Example Tutorial From Scratch - output
Simple Vue js CRUD Example Tutorial From Scratch - output
Angular 6 CRUD Operations Application Tutorials

Read :

Summary

You can also read about AngularJS, ASP.NET, VueJs, PHP.

I hope you get an idea about Simple Vue js CRUD Example Tutorial From Scratch.
I would like to have feedback on my Pakainfo.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Leave a Comment