使用Node.js Express服务器使用Backbone.js pushState路由吗?

使用Node.js Express服务器使用Backbone.js pushState路由吗?,第1张

使用Node.js Express服务器使用Backbone.js pushState路由吗? 说明

首先,您需要知道

domain.com/#/about
它将调用服务器的“
/”路由,因为它不读取#片段。您的服务器将呈现Backbone.js应用程序的基础,而Backbone将触发“关于”路线。

因此,您需要在Express JS中声明两条路由:

  • /
  • /关于
app.get('/', function(req, res) {    // Trigger the routes 'domain.com' and 'domain.com/#/about'    // Here render the base of your application});app.get('/about', function (req, res) {    // Trigger the route 'domain.com/about'    // Here use templates to generate the right view and render});

我建议您通过Derick Bailey与Backbone.js实现SEO兼容性的3个链接:

  • HTML5 PushState的SEO和可访问性,第1部分:PushState简介: http **://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-1-introducing-pushstate/**
  • HTML5 PushState的SEO和可访问性,第2部分:Backbone.js的渐进增强: http **://lostechies.com/derickbailey/2011/09/26/seo-and-accessibility-with-html5-pushstate-part-2-progressive** -加强与骨干js /
  • 使用HTML5 PushState进行SEO和可访问性,第3部分:视频: http **://lostechies.com/derickbailey/2011/10/06/seo-and-accessibility-with-html5-pushstate-part-3-the-video/**


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5127576.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-17
下一篇 2022-11-17

发表评论

登录后才能评论

评论列表(0条)

保存