[Vuejs]-Why Vue treats unspecified boolean props as false?

1👍

You could set a default value on it and check if the value is still the same then the user didn’t pass a prop, but there are instance where you can’t really compare your value to its default, like if the prop is a function.

You could have this.$options.propsData inside of your component. If the prop is present here, the user has explicitly set it; default values aren’t shown in.

Leave a comment