Default value for prop function in VueJS
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:
Related Posts
How to pass data from parent component to child using props in Vue
Find out how to send data from parent component to child component using props in Vue.
Execute a function from child component in Vue
Find out how we can execute a function in the parent component from the child component using emit function in Vue.
Pass multiple objects as props in Vue
Short tutorial on how to pass multiple objects as props to a child component from parent in vue using v-for directive.
How to pass multiple props to component in Vue
Short article on how to pass multiple props to a component in vue using v-bind.
