Tagged: v-on:load

VueJS Call Function on Page Load Example 0

VueJS Call Function on Page Load Example

VueJS Call Function on Page Load Example

In this Post We Will Explain About is VueJS Call Function on Page Load Example With Example and Demo.Welcome on Pakainfo.com – Examples, The best For Learn web development Tutorials,Demo with Example! Hi Dear Friends here u can know to How to Call Vuejs Function on Page Load Example

In this post we will show you Best way to implement Vuejs call function after load, hear for How to trigger a method at page load in vuejs with Download .we will give you demo,Source Code and examples for implement Step By Step Good Luck!.

Vuejs Lifecycle Hooks

There are different Simple lifecycle hooks Vue provide:

How to call a vue.js function on page load

 //some source code....
 methods:{
     getUnits: function() {...}
 },
 beforeMount(){
    this.getUnits()
 },
 //some source code ......

 
///How to Call Vuejs Function on Page Load

vm=new Vue({
  el:"#liveApp",
  mounted:function(){
        this.liveGetData() //liveGetData will execute at pageload
  },
  methods:{
        liveGetData:function(){
              /*Pakainfo.com your logic */
        }
     },
})
 

Simple Structure of the VueJS Applications

// Initializing a create new VueJS instance
new Vue({
 
  // simple get Css selector id of parent some div
  el: '#liveApp',
 
  // initialize vuejs application specific area data
  data: {},
 
  // these vuejs function will simple run when the web- application loads 
  // generally like $(document).ready in jQuery like as a vuejs
  ready: function() {},
 
  // Other vuejs methods we'll use so in the webapplication
  methods: {}
});

How to Call Vuejs Function on Page Load Example

Include External Libs

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
    <script src="http://cdnjs.cloudflare.com/ajax/libs/vue/0.12.16/vue.min.js"></script>
    <script src="js/app.js"></script>

index.html

<!doctype html>
<html lang="en">
<head>
    <title>Getting Simple First started with vue.js</title>
</head>
<body>
    <div class="liveApp" id="liveApp">
        <div class="row">
            <h2>Pakainfo.com Vue.Js Example</h2>
            <div class="form-group">
                <label>Your monthly totalfees:</label>
                <input  type="number"  class="form-control"  placeholder="Enter your monthly totalfees..."  v-model="totalfees"  v-on="blur:showAlert" />
                <p class="help-block" v-if="totalfees">Your Annual totalfees:{{totalfees*12}}</p>
            </div>
        </div>
    </div><!--/#liveApp-->

</body>

index.js

new Vue({
    el: '#liveApp', 
    data: {
        totalfees: 2500,
    },
    ready: function() {
        console.log('Welcome- Vuejs initialized with totalfees 2500');
    },
    methods: {
        showAlert: function() {
          alert("Mr/mss your Annual totalfees: "+this.totalfees * 12);
        }
    }
});

How to Call Vuejs Function on Page Load

You are Most welcome in my youtube Channel Please subscribe my channel. and give me FeedBack.
More Details……
Angularjs Example

Example

I hope you have Got What is Vuejs call function before page load And how it works.I would Like to have FeedBack From My Blog(Pakainfo.com) readers.Your Valuable FeedBack,Any Question,or any Comments about This Article(Pakainfo.com) Are Most Always Welcome.