-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Vue 3 docs are a lot more confusing than vue 2 docs about how we should code #1167
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The addition of the Composition API does pose a challenge from a documentation perspective. It allows projects to adopt significantly different styles and the documentation needs to negotiate that somehow. There's a certain amount of historical momentum in the Vue 3 docs and we're still working to try to address that. In particular, the guides don't give enough emphasis to single-file components, which is something we hope to address going forward. Many of the points you raised are quite subjective and the documentation tries to reflect how Vue is used in the community rather than trying to force everyone to use it in a particular way. I can share my own preferences and try to describe what I've seen elsewhere (mostly in discussions on the Vue Discord) but you'll find differing opinions depending on who you ask.
The Options API is alive and well and is still very popular with many people in the community. I personally use it by default for most components, only using the Composition API for components with more complex needs. I would usually try to avoid mixing the two within a single component though. I know of other teams that have chosen to switch to the Composition API entirely. I don't think this is common but if there's a consensus within your team then it's a perfectly valid option. Personally, I think the Options API is easier for beginners. The coding style required to use the Composition API (which some might call a 'functional style') can be a major obstacle for those who haven't encountered something similar before.
I do not use TypeScript. This is a decision you have to make for yourself, Vue doesn't really push you one way or the other.
In Vue 2, there was a strong case for using 'class component' syntax if you wanted TypeScript. That doesn't really hold true with Vue 3. While it is still supported, I don't think using class components is encouraged.
As I've noted here, wondering about whether to use We do hope to improve the documentation in this area. When used with an object, It is also worth noting that
If you're having trouble with VSCode then make sure you're running the latest version of Volar. |
What an answer, thanks you so much @skirtles-code , your advices are super useful on thoses topics and your issue about reactivity is super interesting too. Everything is subjective but it take so much times to explore by ourselves all the possible alternative, so recommendations feels very great. So for someone like me who:
A possible recommendation could be:
Update: I tried 3) without success, even with "volar" VSCode plugin, my editor becomes crazy about unexisting macros, non-used variables. I'm sticking with defineComponents() for now. |
@yann-yinn From everything you've said, that does sound like an appropriate recommendation for your project. The problems you're having in VSCode might be caused by the Vue ESLint plugin. I haven't experimented with it myself yet but I have seen other people mention a similar problem. Now that Vue 3.2 is officially released, I would imagine any tooling problems would be resolved pretty quickly. |
Seconded on the things that @skirtles-code mentions. We are certainly going through a bit of a challenge in how to embark with docs going forward as more paths open up for developers. That said, we appreciate you bringing up your concern and will keep this in mind as we keep iterating on the docs. Appreciate it @yann-yinn! |
@bencodezen thanks for your anwser. I found a lot of answers by Evan inside this discusion vuejs/rfcs#378 (comment) (thanks @edimitchel for the links). I just understood that using volar, you should disabled vetur |
Closing as we have a new docs now that should have made the explanation more clear |
Uh oh!
There was an error while loading. Please reload this page.
Hi there, (sorry for my inaccurate language, i'm french)
First i want to say how much Vue 3 is better than Vue 2, and how much I love the new composition API; and i know how fucking hard it is to write documentation; kudos for brave people working hard on this.
This issue is pretty meta and only about one thing:
When i first read Vue 2 docs, i was super happy: I knew exactly how to code and, from day one, I was able to code in production. It was so easy: option API, data() for reactivity, no TypeScript, Vuex if I need state management, and i can use <style scoped> for CSS. Let's go ! Code, git push, this is in prod, i'm a Vue developper \o/
But learning Vue 3 and reading the (very good) docs, i was confused because I didn't know how I was suppose to code anymore:
The text was updated successfully, but these errors were encountered: