最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

javascript - What's the bestrecommended way to pass reactive props from components to composables in Vue 3 Composition A

matteradmin5PV0评论

I'm currently trying out Vue 3's Composition API, using a main app and several position funtions, aka 'posables'. I studied official docs and several tuts. It seems there are many ways of acplish the same tasks, so I was wandering what is the best for a couple of things:

  • how to pass reactive variables from the main app to the posables? I mean: should I just pass them as the posable's parameters or should I do it some othe way?

  • how to use other app's methods or other posables from a posable? :)

I'm currently trying out Vue 3's Composition API, using a main app and several position funtions, aka 'posables'. I studied official docs and several tuts. It seems there are many ways of acplish the same tasks, so I was wandering what is the best for a couple of things:

  • how to pass reactive variables from the main app to the posables? I mean: should I just pass them as the posable's parameters or should I do it some othe way?

  • how to use other app's methods or other posables from a posable? :)

Share Improve this question asked Nov 3, 2021 at 16:29 Luca ReghellinLuca Reghellin 8,13515 gold badges84 silver badges132 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 4
  1. You could pass any raw/reactive data as posable parameter, but make sure to make the posable function more independent from the ponent logic (to make it more reusable), you could check Vuetify 3 posable functions and vueuse to get inspired.

  2. Pass them as parameters then run them when needed inside the posable logic.

Articles related to this article

Post a comment

comment list (0)

  1. No comments so far