Home

Issue: 2374

Wrong _uid for this in the transition hooks

[issue link]

I want to access this.$refs and methods for a page component in the transition object. But this referer to different component as they have different _uid? But by the look of it the components are the same, at least have the same this.$el.

I use 1.0.0-rc11 and though it was fixed in https://github.com/nuxt/nuxt.js/issues/566#issuecomment-307667535. But still have some issues.

created () {
   console.log(this._uid); // 57
},

beforeMount() {
   console.log(this._uid); // 57
},

mounted () {
   console.log(this._uid); // 57
},

transition: {
   mode: 'out-in',
   css: false,

   beforeEnter: function (el) {
      console.log(this._uid); // 15
   },

   enter: function (el, done) {
      console.log(this._uid); // 15
      done();
   },

   afterEnter: function (el) {
      console.log(this._uid); // 15
   },

   leave: function (el, done) {
      // I want to be able to do something like this
      // but this.fadeOutMethod is undefined
      // because this refer to a comp with _uid 15, not 57
      this.fadeOutMethod(() => {
         done();
      });
   }
}
This question is available on Nuxt.js community (#c2066)