Default value for prop function in VueJS

featured Image

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

featured Image

How to add common header and footer in vuejs.

Here, in this article, we will learn how to add a common header and footer component in our vuejs application. In general, we always have the same header and footer…

Read more
featured Image

How to call a function in VUE template?

Here, we will learn on how to call a function in vue template. First, we have to define the function in the methods. and then we can use an event…

Read more
featured Image

How to redirect to external url in vue

Here, we will learn how to redirect to an external URL in vuejs application. Page Navigation is one of the basic features of a website. It helps us to navigate…

Read more