Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vue.js ready() method doesn't get called in vue component

I'm using Webpack bundler to serve Vue 2.0 based frontend. The problem is that method ready in components doesn't get called. Do I need to add some extra watch on component or something like that?

My router:

import Vue from 'vue'
import VueRouter from 'vue-router'
import VueResource from 'vue-resource'

import Register from './views/auth/register.vue'

Vue.use(VueRouter);
Vue.use(VueResource);

const routes = [
  { path: '/auth/register', component: Register } 
]

const router = new VueRouter({
  routes // short for routes: routes
})

export default router;

and my sample component:

<template>
    <div>
        <div class="message">{{ msg }}</div>
    </div>
</template>

<script>
export default {

    data: function () {
        return {
            msg: 'Hello from vue-loader!'
        }
    },

    ready: function() {
        console.log('test');
    }
}
</script>
like image 208
Luke Avatar asked Jan 16 '17 15:01

Luke


1 Answers

ready() lifecycle hook method is depracated in VueJS 2.0.x.Use mounted() or created() instead.

like image 190
Belmin Bedak Avatar answered Sep 21 '22 02:09

Belmin Bedak