Default value for prop function in VueJS

vuejs1 min read

The article is about how to set default value for function prop in vuejs. For props like Function and O

In this article we will learn how to set a default value for prop which is a function.

In Vuejs, props are properties which are use to send data from a parent component to its child component.

For props type like Functions, Array and Objects, the default value must be a returned function.

Default value for function props in Vuejs

props: { getData:{ type: Function, default: function () { return 1; } } },

In this example, the default value is a Function which returns us a value 1.

Related Topics:

How to set default value of props in VueJS ?

How to listen for props changes in VueJS?

Related Posts