[Vuejs]-Vue.js โ€“ Keep Alive Component โ€“ Error next Tick

0๐Ÿ‘

Ok. So your problem here is the wrong life-cycle hook.

If you change created to activatedโ€ฆ it should work. It did for me in your JS fiddle.

activated:function (){
    setTimeout(() => this.asyncData = 'Async Data was loaded' , 1000)
}

There are two other hooks, activated and deactivated. These are for keep-alive components, a topic that is outside the scope of this article. Suffice it to say that they allow you to detect when a component that is wrapped in a tag is toggled on or off. You might use them to fetch data for your component or handle state changes, effectively behaving as created and beforeDestroy without the need to do a full component rebuild.

SOURCE: here

๐Ÿ‘คpeaceman

Leave a comment