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

The property's default value is wrong when the property type is a function #1348

Closed
tangjinzhou opened this issue Jun 12, 2020 · 1 comment · Fixed by #1349
Closed

The property's default value is wrong when the property type is a function #1348

tangjinzhou opened this issue Jun 12, 2020 · 1 comment · Fixed by #1349

Comments

@tangjinzhou
Copy link
Contributor

Version

3.0.0-beta.14

Reproduction link

https://jsbin.com/lumofirepo/edit?html,output

Steps to reproduce

props: {
   getSome: {
       type: Function,
       default: () => "some"
   }
},

What is expected?

this.getSome is function

What is actually happening?

this.getSome is some

tangjinzhou pushed a commit to tangjinzhou/vue-next that referenced this issue Jun 12, 2020
@pikax
Copy link
Member

pikax commented Jun 12, 2020

AFAIK the props spec is the same as v2

Based on the docs:

Specifies a default value for the prop. If the prop is not passed, this value will be used instead. Object or array defaults must be returned from a factory function.

If you passing a function it will be treated as a factory functions, you can fix your example by:

      //default: () => "some"
      default: () => ()=> "some"

@github-actions github-actions bot locked and limited conversation to collaborators Nov 11, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants