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 {}
        }
    }
}

就可以了。

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

原文地址:https://www.cnblogs.com/yanggb/p/12652132.html