Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: missing vue special method #169

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

barnett617
Copy link

First, thanks for this project for helping old projects' migration ♥️.
I got a bug while using this project to migrate my project because there has some code like below:

@Component
export default class Test extends Vue {
    created() {
        document.addEventListener('mousedown', onMousedown);
    }
    onMousedown() {
        console.log('mousedown');
    }
    beforeDestroy() {
        document.removeEventListener('mousedown', onMousedown);
    }
}

this code was migrated into below:

import { defineComponent } from "vue";

export default defineComponent({
    created() {
        document.addEventListener('mousedown', onMousedown);
    },
    methods() {
        onMousedown() {
            console.log('mousedown');
        },
        beforeDestroy() {
            document.removeEventListener('mousedown', onMousedown);
        }
    }
})

This will miss the event unregister after the component destroyed because the special method "beforeDestroy" was incorrectly migrated into methods. It cause unexpected event handles in my project.

So I create this PR to fix this bug about "beforeDestroy" using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant