Skip to content
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

setBase is working? #156

Closed
01oseluiz opened this issue Mar 16, 2021 · 1 comment
Closed

setBase is working? #156

01oseluiz opened this issue Mar 16, 2021 · 1 comment
Assignees

Comments

@01oseluiz
Copy link

01oseluiz commented Mar 16, 2021

Hi,

I try to use "setBase" and nothing happens, actually i don't understand the functionality of it.

what did I try:

<app>
    <router>
        <a href="/home">Slash Home</a>
        <a href="/#/home">Hash Home</a>
        
        <route path="/home">
            <h1>Slash Home</h1>
        </route>
        <route path="/#/home">
            <h1>Hash Home</h1>
        </route>
    </router>

    <script>
        import { Route, Router, setBase} from '@riotjs/route'

        export default {
            components: {
                Route,
                Router
            },
            onBeforeUpdate() {
                setBase(`#`)
            }
        }
    </script>
</app>

And using setBase(`#`) or setBase(`/') or <router base="#"> or <router base="kajshdf"> does the same

EDIT:
After some debug, i was able to use it with <router base={"#"} > instead of <router base="#" >

But this broke my first request, because "replaceBase" function at "rawth.replaceBase" can't remove base from the default initialRoute. Once my normalized base is = "http://localhost:3000#" and the current initial route is "http://localhost:3000/", the replace doesn’t match.

So i'm passing as attribute an initialRoute too, like: <router base={"/#"} initialRoute={window.location.hash.replace('#', '') || '/'}> this way my routes are http://localhost:300/#/home

@GianlucaGuarini
Copy link
Member

@01oseluiz thank you for your feedback this issue has been fixed in v7.1.0 please use <router base="#">.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants