ExpressJS更改路由而不刷新 [英] ExpressJS change route without refresh

查看:172
本文介绍了ExpressJS更改路由而不刷新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿,我有一个运行 Express.js Handlebars 的网站,该网站的导航栏和侧边栏在所有页面上都保持不变.当我路由时,它只会更改{{{body}}}的页面容器.

Hey I have a website run with Express.js and Handlebars that has a navbar and sidebar that stays the same for all the pages. When I route it only changes the page container which is {{{body}}}.

有没有一种方法可以直接加载路线内容,而无需页面实际刷新和重新加载导航栏和侧边栏?

Is there a way I can just load the content of the routes without the page actually refreshing and reloading the nav and sidebar?

我目前正在使用它进行路由.

I'm currently using this for routing.

router.get('/', checkAuthentication, function(req, res){
  res.render('index');
});

任何帮助都会很好,因为我对node还是很陌生.

Any help would be nice as I'm quite new with node.

我只希望容器加载而不是整个网址/页面

I want only the container to load not the whole url/page

推荐答案

谢谢大家考虑/查看这篇文章,我得出的结论是使用 PJAX 来做到这一点.

Thank you all for considering/looking at the post, i have come to the conclusion to be using PJAX to do this.

我读过的教程,对于任何想知道的人都是:

The tutorial i read, for anyone wondering is : Pjax Tutorial

这篇关于ExpressJS更改路由而不刷新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆