props with type object/array must use a factory function to return the default value

Posted yanggb

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了props with type object/array must use a factory function to return the default value相关的知识,希望对你有一定的参考价值。

vue的报错信息已经很清晰了,只要把props中的

props:{
    obj:{
        type: Object,
        default: {}
    },
},

修改为:

props:{
    obj:{
        type: Object,
        default: function() {
            return {}
        }
    },
}

props:{
    obj:{
        type: Object,
        default: () => {
            return {}
        }
    }
}

就可以了。

 

"会让我失望的事,也从来没有辜负过我。"

以上是关于props with type object/array must use a factory function to return the default value的主要内容,如果未能解决你的问题,请参考以下文章

props with type object/array must use a factory function to return the default value

Vue 提示Invalid default value for prop “tableData“: Props with type Object/Array must use a factory(代码

vue错误:Invalid prop: type check failed for prop “autofocus“. Expected Boolean, got String with value

vue错误:Invalid prop: type check failed for prop “autofocus“. Expected Boolean, got String with value

vue错误:Invalid prop: type check failed for prop “autofocus“. Expected Boolean, got String with value

VUE props的坑(Props with type Object/Array must use a factory function to return the default value)(代码