且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在Vue.js中的页面加载时触发方法?

更新时间:2023-12-05 17:37:28

对于vue> = 2.0 使用mounted,对于以前的版本使用ready.

For vue >= 2.0 use 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 */
        }
     },
})