ItalyPaleAle / svelte-spa-router

Router for SPAs using Svelte 3
MIT License
1.56k stars 106 forks source link

<Pages> was created with unknown prop 'params' #324

Closed exqmjmz closed 4 months ago

exqmjmz commented 4 months ago

image

<script lang="ts">
  import Router from "svelte-spa-router";
  import {location} from 'svelte-spa-router'
  import Sidebar from "@/lib/components/ui/siderbar/siderbar.svelte";
  import Header from "@/lib/components/ui/header/header.svelte";
  import { PageRoutes,DetailRoutes } from "@/routers/routers";
  import { onMount } from "svelte";
  const prefix = "/app";
  const routes = PageRoutes;
</script>
<div
  class="min-h-screen flex flex-col flex-auto flex-shrink-0 antialiased bg-gray-50"
>
  <div class="fixed flex flex-col top-0 left-0 w-64 bg-white h-full border-r">
    <div class="flex items-center justify-center h-14 border-b">
      <div class="font-bold text-xl">xxxxxxxxxxxxxxxxxxx</div>
    </div>
    <Sidebar />
  </div>

  <div class="ml-64 flex flex-col">
    <Header />

    <main class="flex-grow bg-white m-4 p-4 rounded-md shadow-md">
      <Router {routes} {prefix}/>
    </main>
  </div>
</div>

The error is located const routes = PageRoutes; What is the reason for this error?

Page routes can jump, but errors will occur in the console.

svelte:4.2.12

carbogninalberto commented 4 months ago

This warning is just let you know as a dev that the "params" prop is passed to the component but you didn't export it.

To fix it, add export let params;.

In the documentation, you can find more info, take a look for example at: https://github.com/ItalyPaleAle/svelte-spa-router/blob/main/Advanced%20Usage.md#async-routes-and-loading-placeholders

exqmjmz commented 4 months ago

This warning is just let you know as a dev that the "params" prop is passed to the component but you didn't export it.

To fix it, add export let params;.

In the documentation, you can find more info, take a look for example at: https://github.com/ItalyPaleAle/svelte-spa-router/blob/main/Advanced%20Usage.md#async-routes-and-loading-placeholders

I have already exported the routing component, but the problem still exists image

carbogninalberto commented 4 months ago

In your Pages.svelte?

exqmjmz commented 4 months ago

In your Pages.svelte?

oh,i know!thank