chikadance
chikadance

Reputation: 4167

Is there way to hook vue component ready (initialize)

see my demo, I hope hook component ready with following code:

<body>
<div id="app">
  <ro-tag></ro-tag>
</div>
<script>
  Vue.component("ro-tag", {
    ready: function () {
      console.log("ready")
    },
    template: "<div></div>"
  })
  new Vue({el: "#app"})
</script>
</body>

the ready function isn't invoked.

Upvotes: 1

Views: 3184

Answers (1)

Saurabh
Saurabh

Reputation: 73609

ready has been replaced with mounted hook in vue 2.x.x. you can use mounted hook which gets:

Called after the instance has just been mounted where el is replaced by the newly created vm.$el

see updated fiddle.

Upvotes: 1

Related Questions