vuejs / vuepress

📝 Minimalistic Vue-powered static site generator
https://vuepress.vuejs.org
MIT License
22.58k stars 4.76k forks source link

beforeDestroy for dynamic component hook lose direct access to this data/props #2485

Open mmc41 opened 4 years ago

mmc41 commented 4 years ago

Bug report

beforeDestroy lifecycle hook are not able to access props and data normally using "this".

Steps to reproduce

Add a beforeDestroy lifecycle hook to a dynamic Vue component with props+data in Vuepress.

Set breakpoint and navigate away. beforeDestroy will be called but the props+data no longer available directly using "this". They can however be found using this.$data and this.$props

What is expected?

props + data should be available using "this" just as it is when hooking into mounted()

What is actually happening?

Not directly available unless one look under $data and $props.

Other relevant information

Also, an instance variable imported on top of the script is also undefined in beforeDestroy..... Maybe beforeDestroy is called to late after things are in fact destroyed ?

Environment Info:

System: OS: macOS Mojave 10.14.6 CPU: (8) x64 Intel(R) Core(TM) i7-3770 CPU @ 3.40GHz Binaries: Node: 12.13.0 - /usr/local/bin/node Yarn: Not Found npm: 6.12.0 - /usr/local/bin/npm Browsers: Chrome: 83.0.4103.116 Edge: Not Found Firefox: 78.0.1 Safari: 13.1.1 npmPackages: @vuepress/core: 1.5.2 @vuepress/theme-default: 1.5.2 vuepress: 1.5.2 => 1.5.2 npmGlobalPackages: vuepress: Not Found

AlexMerkishev commented 4 months ago

Same problem, still not fixed "vue": "^2.7.4",