Comments (13)
@UIX-Design Hello there. This is not related to the router itself. It depends on your local server configuration. When you enter the URL directly into your browser, the localhost server (node express, Apache, ngnix, etc.) must serve the index.html which is not a default behavior of server - it tried to open a index file in the given directory. I.e. you have to setup rewrite rules to serve the index.html. As soon as the index.html is shown, than the URL changes are done directly by the router.
from svelte-router.
@davidhorak OK thank you for your detailed answer. Later, when I build my Svelte app and deploy to a server, I try to use the following rewrite rules:
<ifModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [QSA,L]
</ifModule>
Is there a way to fix the problem in the dev environment, so if I'm running npm run dev
?
from svelte-router.
@UIX-Design That should work for apache. For the dev, it depends how you run the local server. What does the "dev" script do/runs?
from svelte-router.
@davidhorak the dev script run the following commands:
"dev": "run-p build:auto serve:dev"
Another question: The activeClass
works great, but i am using a dropdown menu like this:
{#if open}
<nav in:slide out:slide class="">
//my dropdown menu
</nav>
{/if}
The activeClass
does not keep on my dropdown menu if it is not displayed again. How can I solve this?
from svelte-router.
@UIX-Design Assuming that "serve:dev" is webpack dev server than - https://stackoverflow.com/questions/31945763/how-to-tell-webpack-dev-server-to-serve-index-html-for-any-route
from svelte-router.
@davidhorak thanks for sharing the link, but how can i edit or expand the webpack.config.js? I am a newcomer of Svelte... And please take a look at my updated comment to my activeClass Issue... Thanks for your help
from svelte-router.
@UIX-Design Respectfully, this is not related to Svelte, nor this router repository, rather the webpack basics, please explore the https://webpack.js.org/guides/getting-started/ to see how to setup the webpack config.
from svelte-router.
@UIX-Design Regarding the activeClass, also not sure if this is related to the router, but rather to your app structure.
from svelte-router.
@davidhorak When i open my dropdown and click on a link:
The activeClass is hello
- looks good
After i close and open the dropdown again...
The active link does not retain the activeClass
even though the page has not been left...
from svelte-router.
@davidhorak I think i have a solution for my activeClass Issue... It is possible to get the current route, inside a component?
from svelte-router.
@UIX-Design yes, https://github.com/spaceavocado/svelte-router#auto-passed-route-prop
from svelte-router.
@davidhorak thank you very much. One last question: It is possible to use the Link Events like on:completed={handleOnCompleted}
on the router layer, maybe inside the createRouter
function? Because i want to pass a prop to my header comp, there is located in the App.svelte
- the same place for my route config.
from svelte-router.
@UIX-Design you can you these router level event handlers: https://github.com/spaceavocado/svelte-router#onnavigationchanged https://github.com/spaceavocado/svelte-router#onerror or https://github.com/spaceavocado/svelte-router#onbeforenavigation
from svelte-router.
Related Issues (16)
- Transitions support HOT 6
- RouterLink does not output attributes passed HOT 3
- Store Router not updating HOT 2
- whats is the Status of this project HOT 4
- $router.push() and $route.replace() do not update the destination component route prop when the source and destination component are the same HOT 2
- Query parameters are not encoded
- Upon reloading, the route is broken, I am not able to find a solution to this. Is there any way to redirect the user to proper route on reload? Even the routes in the example(webpack) are broken if reloaded.? HOT 1
- Optional parameters in the URL cause crash in isWholeNumber
- Callbacks: "to, from" versus "from, to" HOT 3
- Prevent Navigation on select child elements HOT 10
- TypeError: de is undefined when selecting a link produced by <RouterLink> HOT 1
- Svelte:Head doesn't update, when switch between pages HOT 5
- Support for Analytics like Matomo HOT 7
- RouterLink invalid route parameters HOT 5
- Home absolute path HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from svelte-router.