11월 20, 2022의 게시물 표시

Publish to my blog (weekly)

Composables | Vue.js stateful logic involves managing state that changes over time. A simple example would be tracking the current position of the mouse on a page. // by convention, composable function names start with "use"   export function useMouse () { As we can see, the core logic remains identical - all we had to do was move it into an external function and return the state that should be exposed. Just like inside a component, you can use the full range of Composition API functions in composables. The same useMouse() functionality can now be used in any component. Each component instance calling useMouse() will create its own copies of x and y ...