-
-
Couldn't load subscription status.
- Fork 33.8k
Description
Consider a component caled Box with the following property:
export default { props: { type: { type: String, default: "text" } } }The intension of the component designer here is that anything we don't have a meaningful input for "type", it should be "text".
In Vue it seems that defaults are assigned only if the property is omitted. Consider the following example of using the box component.
<template> Box type: <box :type="box_type" /> Box text type: <box /> </template>In the first case if "box_type" is defined, this works well and good. If "box_type" is undefined for whatever reason, this causes the Box component's type property to be unset and a warning to be issued in the console.
The second usage of works as expected and the property defaults to "text".
Should undefined property values cause defaults to be assigned? I think it would make for a nicer development practice.