How to trigger a method at page load in vuejs?
For vue >= 2.0use mounted
and for previous version use ready
.
vm=new Vue({ el:"#app", mounted:function(){ this.method1() //method1 will execute at pageload }, methods:{ method1:function(){ /* your logic */ } },})
This syntax is working fine:
export default { mounted() { this.myMethod() },}