Skip to content
Advertisement

Null boolean props if not given in Vue?

In a Vue component, I have this:

JavaScript

If I call my component without foo:

JavaScript

I read false on the console. I would like to get null if the property is not given and the boolean value elsewhere.

How can I get this?

Advertisement

Answer

You could add default value :

JavaScript
Advertisement