ItalyPaleAle / svelte-spa-router

Router for SPAs using Svelte 3
MIT License
1.53k stars 105 forks source link

children router bug #323

Closed allmors closed 3 months ago

allmors commented 3 months ago

The type of effect I want is vue-router routing with nested sub-routing. Here is my example. My different paths correspond to different components, but the plug-in seems to be that if this path is used by other routes, the same type cannot be used. image image image

Unable to achieve effect

const routes = {
    '/:blacklist': BlackList,
    '/:setting': Setting,
}

can achieve the effect

const routes = {
    '/:blacklist': BlackList,
    '/:setting/:xxx': Setting,
}

But what I want is that different components can be used with different pathnames in the relevant cascade

In short, it is as follows:

const routes = {
    '/:blacklist': BlackList,
    '/:setting': Setting,
}
ItalyPaleAle commented 3 months ago

Do you set the prefix to the sub-routers? See docs/examples: https://github.com/ItalyPaleAle/svelte-spa-router/blob/main/Advanced%20Usage.md#nested-routers

allmors commented 3 months ago

Do you set the prefix to the sub-routers? See docs/examples: https://github.com/ItalyPaleAle/svelte-spa-router/blob/main/Advanced%20Usage.md#nested-routers

Yes, there is a setting

image

I found a problem. It was my mistake. My routing used the form of params, which caused the routing failure problem.

Incorrect example

const routes = {
    '/:blacklist': BlackList,
    '/:setting': Setting,
}

Correct example

const routes = {
    '/blacklist': BlackList,
    '/setting': Setting,
}

Thanks for your answer