props注意点

props注意点:对象的时候设置默认值不能直接()=>{},这样返回的是undefined,需要()=>{return {}}

props:{
    initData: {
        type: Object,
        default: ()=>{
            return {}
        }
    },
    filterList: {
        type: Array,
        //效果和data为什么是函数一样
        default: ()=>[]
    }
}
复制代码

错误写法:

props:{
    initData: {
        type: Object,
        default: ()=>{}//返回是undefined
    }
}
复制代码
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享