rogerpadilla / prouter Goto Github PK
View Code? Open in Web Editor NEWFast, unopinionated, minimalist client-side routing library inspired by the simplicity and flexibility of express middlewares
License: MIT License
Fast, unopinionated, minimalist client-side routing library inspired by the simplicity and flexibility of express middlewares
License: MIT License
<script src="https://unpkg.com/prouter/prouter.min.js"></script>
<script>
const router = prouter.browserRouter();
router
.use('/abc', function (req, res) {
alert(1);
})
.use('*', function (req, res) {
alert(2);
})
router.listen();
</script>
router.push('/abc')
returns 2
change router:
.use('/abc', ..) => .use('abc',..)
now it returns 1
Hi, โ
I'm building a small PWA using a prouter. By reading the PWA checklist I saw that is a good practice to retain scroll position from the previous page when user presses back.
Imagine a list of a product, the user scroll to the bottom of the list, pick a product and go to the detail page. Then he goes back to the list. In this case, it's good to restore the scroll position.
It can be a nice to have feature in prouter. What do you think ?
When calling .navigate
from a page where the user has scrolled down, the window will still be positioned where it was instead of going back to the top like normally happens when clicking links.
Currently, if the 'hash' in the URL is changed, prouter will always see it as a change in the path.
Provide a way to ignore 'hash' changes.
API could be something like
router.on('navigation', (navigationEvent) => {
//...
}) ;
This may seem like a dumb issue but I can't seem to load prouter. I've tried regular script tags and requirejs, and failed miserably. According to readme.md either method should work.
The file I've been trying to load is dist/index.js as it's the only js file that isn't a configuration file. I must be doing something wrong but I have no idea what it is. Care to point me in the right direction (and amend readme.md so other dummies like me don't get stuck right away)? :)
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.