Vue 父组件传递给子组件,设置默认值为数组或者对象时
在vue 父子组件传参过程中,传递对象或者数组时,设置默认值为{}或者[]
错误写法:
props: { pos: { type: [Object, Array], default: []//这是错误的!!! } },
正确的写法:
props: { pos: { type: [Object, Array], default: function(){ return [] } } },
在vue 父子组件传参过程中,传递对象或者数组时,设置默认值为{}或者[]
错误写法:
props: { pos: { type: [Object, Array], default: []//这是错误的!!! } },
正确的写法:
props: { pos: { type: [Object, Array], default: function(){ return [] } } },