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

Props with type Object/Array must use a factory function to return the default value. #4

Open
zuobaiquan opened this issue Nov 6, 2017 · 2 comments

Comments

@zuobaiquan
Copy link
Owner

zuobaiquan commented Nov 6, 2017

slideItem:{
      type : Array ,
      default: ['列表一','列表二','列表三']
 }

[Vue warn]: Invalid default value for prop "slideItem": Props with type Object/Array must use a factory function to return the default value.

应该改为如下

slideItem:{
      type : Array ,
      default: ()=> ['列表一','列表二','列表三']
 }

参考 vuejs/vue#1032

@EdwinBetanc0urt
Copy link


props: {
    propObject: {
        type: Object,
        default: () => ({
            value1: '',
            value2: '',
            value3: '',
        })
    },
    propArray: {
        type: Array,
        default: () => ([
            "a",
            "b",
            "c"
        ])
    }
},

vuejs/vue#1032

@StanleyMasinde
Copy link


props: {
    propObject: {
        type: Object,
        default: () => ({
            value1: '',
            value2: '',
            value3: '',
        })
    },
    propArray: {
        type: Array,
        default: () => ([
            "a",
            "b",
            "c"
        ])
    }
},

vuejs/vue#1032

This one worked for me. I wonder why this issue is still open 🤔

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

3 participants