visionmedia / page.js

Micro client-side router inspired by the Express router
http://visionmedia.github.com/page.js
7.67k stars 687 forks source link

option click true doesn't work #404

Closed Nomia closed 6 years ago

Nomia commented 7 years ago

Hi, I love this router coz it looks simple.

But I've got one problem when use page.js in my project yesterday. 1.the option {click:true} does'nt work, I know the click value is true by default, but it doesn't seem to work in my case, so I set it to true, still doesn't work => When I click the a tag, the page will refresh. below is the code:

index.html

<body>
<a href='/docs'>docs</a>
<script type='text/javascript' src='/path/to/my/build.js'></script>
</body>

index.js

// version 1.7.1
const Page = require('page');
Page.base('/mobile');
Page('/docs', () => {
    console.log('docs');
});
Page({
   hashbang: true,
   click: true
});

the build.js file is executed properly.

eth0lo commented 7 years ago

I think your problem there is because your are setting your base as /mobile that means that all routes that page handles must start with /mobile, that said you need either to update your link to point to /mobile/docs or get rid of the base config altogether

Nomia commented 7 years ago

Thanks for you reply @eth0lo ,I'll give it a try, for now, I've implemented the click in my own way.

matthewp commented 6 years ago

Looks like this was solved!