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

我们需要页面路由! #8

Open
kahakaha opened this issue Nov 7, 2023 · 1 comment
Open

我们需要页面路由! #8

kahakaha opened this issue Nov 7, 2023 · 1 comment

Comments

@kahakaha
Copy link
Collaborator

kahakaha commented Nov 7, 2023

svelte是如何进行页面路由的呢,让我们一起来看看他们的文档中是怎么说的吧

点我看看

显然我们没有用到SvelteKit, 但是在文档其中列出的许多很多可以替代的工具,比如svelte-spa-router

大家也可以了解一下其他的路由插件,可以在下面和我交流一下。

@kahakaha
Copy link
Collaborator Author

kahakaha commented Nov 7, 2023

我个人比较倾向于用svelte-spa-router

可以看看它的一个例子

import Home from './routes/Home.svelte'
import Author from './routes/Author.svelte'
import Book from './routes/Book.svelte'
import NotFound from './routes/NotFound.svelte'

const routes = {
    // Exact path
    '/': Home,

    // Using named parameters, with last being optional
    '/author/:first/:last?': Author,

    // Wildcard parameter
    '/book/*': Book,

    // Catch-all
    // This is optional, but if present it must be the last
    '*': NotFound,
}

这种路由写法很像Vue里面router的写法,可能后续各位要写Vue的时候会更加容易上手?

@kahakaha kahakaha changed the title 我们需要路由! 我们需要页面路由! Nov 7, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant