2 min read
Modified7 months ago. I have this method updateLocation calling location. but I get context.location is not a function. (In 'context.location()', 'context.location' is undefined).
I also tried without context. and also calling the method works from other functions; just not from emit apparently. 3838 bronze badges. 1,42122 gold badges1818 silver badges4040 bronze badges.
1818 silver badges4040 bronze badges. 3838 bronze badges. The context parameter has only 3 properties emit, attrs and slots, you could pass location by props like :.
1414 gold badges105105 silver badges129129 bronze badges. 129129 bronze badges. No need to use context if the function is within the same scope.Just give it a different name or it will shadow the variable location.
22 gold badges1212 silver badges3131 bronze badges. 3131 bronze badges. at DANA we are always improving our code quality & app performance. This is important for us to do. And the good news is that in Vue 3 there is a Composition API feature that aims to overcome the limitations and weaknesses of the Options API.
We will learn more about Vue 3 Composition API, to make it easier for us to understand the Composition API, I have created a Todo App project and you can directly see my code on GitHub in this repo. You can also access the Todo app demo that has been created at this link. In Composition API we will learn Ref, Reactive, toRefs, Methods, Computed Getter & Setter, WatchEffect, Watch, Lifecycle, Component (Props & Emit). Composition API in Vue 3 is optional, at the time this article was written programmers could still use the Options API in Vue 3 for Web App Development.
The Composition API was created to overcome the limitations of Option API.
Composition API feels useful in large and complex applications. This is because the concept of Composition API is to separate several logical concerns and even make the logic reusable.
An example is :. The code above is an example for separating logical concerns, while for how to make a function reusable, suppose we want to create a function to store data into LocalStorage.