Skip to content

Data method of components to be called with this #6739

@cathrinevaage

Description

@cathrinevaage

What problem does this feature solve?

When a computed value is computed, it's called with this as a parameter.
This allows us to write code like this:

computed: {
  isHome: ({ $route }) => $route.name === 'home',
}

The same can't be done with the data method, due to it not being called with this.

What does the proposed API look like?

data: ({ $someProperty }) => ({
  someString: $someProperty.someString + " + something else",
}),

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions