Composition API
Learn about the drawbacks of Options API and how Composition API manages stateful logic.
We'll cover the following...
Composition API can be used in a few different ways to manage and reuse stateful logic. Let’s start with a simple example of tracking scroll position and converting the functionality from Options API to Composition API.
Options API
Let’s start with the tracking scroll position example with ...
export default {data() {return {scrollY: window.scrollY,};},methods: {onScroll() {this.scrollY = window.scrollY},},created() {window.addEventListener("scroll", this.onScroll, false);},beforeUnmount() {window.removeEventListener("scroll", this.onScroll, false);},}
The problem with Options API is that functionality for this specific feature is spread across different parts ...
Ask