Skip to content

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

@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

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy