I used Vue decorator notation like this:
@Prop({ type: Object || null, default: null })
in Vue documentation I saw notation by array:
@Prop({ type: [ Object, null ], default: null })
but does the notation through the sign || is that wrong?
CodePudding user response:
You can use it like so, but it's not the right way.
See Logical OR (||). If you set null || Object
you will get Object
, because Boolean(null)
is false
. In your variation you will get Object
because Boolean(Object)
is true
. But you can use it like this:
@Prop({ type: Object, default: null })
Not only in an array way ([Object]
).