-
-
Notifications
You must be signed in to change notification settings - Fork 5k
Design for Vue 3 #3124
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
Hello, it's great you want to help, we could definitely use some help! However I need you to wait a little bit more (few weeks) as there is already a lot of work already done for the next version of vue router and porting the current version would be a waste of time. Good news is 1 and 2 are already that way. If you find things while using the package linked above, please post them here (even if the issue is closed) and ping me until the repo for vue-router-next is public and discussions can happen there with pointers at the source code as well |
@posva cool, thanks. I'll try it tomorrow. I'm only doing basic stuff but if I find something I'll let you know. |
@posva I'm only doing basic stuff but seems to work well enough! Feedback:
|
Thanks! I'm fixing the types and publishing a new version For the other 3 points: the idea behind always passing |
oh, I was mislead by the name Now I see that it's actually the html5 implementation. |
Here's another piece of feedback: I had a funny issue with that declaration, though. I wanted to inject the router in my component and encountered this problem: microsoft/TypeScript#36812. I don't think that you have to redeclare the generic |
Probably something like I was aware of the problem, and we will likely expose functions named |
I agree having a
What I ended up doing is this: Because this |
@posva Can you export the Link and View components so we can easily consume them from JSX/TSX? |
@mehcode yeah, this time it's possible because we only have named exports |
@posva |
@hareku it's published 🙂 Keep in mind the naming of exports is subject to change |
Seems like empty route ('/') doesn't work if the name is not provided. const routerHistory = createWebHistory();
const router = createRouter({
history: routerHistory,
routes: [
{ path: '/', component: Home }, // note that name is not provided
{ path: '/user/:id', component: User },
],
});
const app = createApp(App);
|
@Destiner That was already fixed but not released yet |
There are a few more things to pickup at https://github.com/vuejs/vue-router-next/projects/2 right now. Let me know if you are working on something so I can move the task on the board |
What problem does this feature solve?
The roadmap for Vue 3 says it will release Q1 2020 and the core lib is already very usable.
I think now is the right time to port vue-router, which is a must-have for many apps.
The exercise may provide interesting feedback on Vue3 public APIs.
I could help porting the code but I'm unsure of some design decisions.
What does the proposed API look like?
1. Setup
install
could be an instance function onVueRouter
so that one could register it like that:What
install
does is:router-link
androuter-view
;Router
at the root of application.Route
ref as well? It's available through the router object.I'll talk more about injecting value next.
If someone wants more control (e.g. use different name for components or not register them globally), those tasks can easily be made manually instead of using
.use(router)
.2. Accessing the router
There is no global mixins
$router
,$route
anymore.If a component (userland, or internally in
router-view
androuter-link
) needs to access the router, e.g. to navigate, it injects the router in setup:let router = inject('Router')
.The route can be found on the router, or could be provided as
Route
(ref).Nesting routers can be done be re-providing those keys.
3. Guards
This is what I'm having most trouble with.
Currently
vue-router
does some ugly hacks to get hold of component instances that are navigated to/from, in order to callbeforeRouteEnter
,beforeRouteUpdate
andbeforeRouteLeave
.I'm hoping the new API could look something like:
but I'm not clear about how fine details would work. Such as:
setup
always called, even when usingkeep-alive
?With some feedback on the design and a few pointers for the last point, I can have a try at porting this component.
BTW: 300Mo of dependencies to build a 20Ko lib is crazy :(
The text was updated successfully, but these errors were encountered: