Adding Global Properties and Custom Directives API

Learn the new way of adding global properties and custom directives in Vue 3.

Adding global properties

Let’s look at how we deal with global properties in Vue 2 and Vue 3.

Vue 2 and Vue 3

In Vue 2, we could add a new property on Vue’s prototype to make a value available in all components. For instance, we could add a global debug method by doing this:

Get hands-on with 1200+ tech skills courses.