Skip to content

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

Open
@EO2875

Description

@EO2875

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()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions