Skip to content

"this.$options is undefined" is being raised when using vue async computed #120

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

Open
EO2875 opened this issue May 1, 2022 · 0 comments
Open

Comments

@EO2875
Copy link

EO2875 commented May 1, 2022

At some point in my component I wanted to do this:

export const {
    methods: {
        mymethod() {
            this.$options.data // Does not raise error
            const originalData = this.$options.data() // TypeError: this.$options is undefined
        }
    },
}

I checked the console and this.$options.data gets overwritten by vue-async-computed to be vueAsyncComputedInjectedDataFn, and the error is in this line:

    for (var key in asyncComputed) {
        var item = this.$options.asyncComputed[key];

In my component, this solves the error:

mymethod() {
    this.$options.data.call(this)
}

However, I think this problem should be fixed from vue-async-computed's side, not from the developer side. As I understand, the Vue API allows us to simply call this.$options.data()

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

No branches or pull requests

1 participant