I have a problem with page.js
routing. If I go from settings
to a dashboard
, i get the passed in props. If I go from dashboard
to dashboard
nothing is logged out... Can anyone help?
App.svelte
let page, props;
router("/settings", () => (page = Settings));
router("/dashboards/:dashboardId", (ctx) => {
props = ctx.params;
console.log("App", props);
page = Dashboard;
});
<svelte:component this={page} {...props} />
Navigation.svelte
{#each $dashboards as dashboard}
<div class="dashboard-link">
<a href="/dashboards/{dashboard.id}">{dashboard.name}</a>
</div>
{/each}
Dashboard.svelte
<script>
export let dashboardId;
console.log("dashboardId", dashboardId);
</script>
The code actually works. The problem was that the console.log
works only during initialization ie from settings to dashboard, dashboard loads. From dashboard to dashboard, only the variables change ie component is already loaded.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.