为了账号安全,请及时绑定邮箱和手机立即绑定

backbone.js history 里的 pushState 究竟是什么含义?

backbone.js history 里的 pushState 究竟是什么含义?

繁星淼淼 2019-03-29 22:09:35
pushStatesupportexistsonapurelyopt-inbasisinBackbone.Olderbrowsersthatdon'tsupportpushStatewillcontinuetousehash-basedURLfragments,andifahashURLisvisitedbyapushState-capablebrowser,itwillbetransparentlyupgradedtothetrueURL.NotethatusingrealURLsrequiresyourwebservertobeabletocorrectlyrenderthosepages,soback-endchangesarerequiredaswell.Forexample,ifyouhavearouteof/documents/100,yourwebservermustbeabletoservethatpage,ifthebrowservisitsthatURLdirectly.Forfullsearch-enginecrawlability,it'sbesttohavetheservergeneratethecompleteHTMLforthepage...butifit'sawebapplication,justrenderingthesamecontentyouwouldhavefortherootURL,andfillingintherestwithBackboneViewsandJavaScriptworksfine.看不太懂这一段,能举一个例子吗?
查看完整描述

2 回答

?
Qyouu

TA贡献1786条经验 获得超11个赞

自问自答一下吧,之前旧的浏览器只能通过hashchange来判断单页app地址的变化,而由于html5historyapi的出现,允许通过/path这样的模式来渲染页面,这种模式就叫做pushState,pushState设为true意味可以采用这种模式。在backbone里面,会判断浏览器对historyapi的支持,不支持的浏览器自动降格为hashchange的方式来切换页面。
                            
查看完整回答
反对 回复 2019-03-29
  • 2 回答
  • 0 关注
  • 586 浏览
慕课专栏
更多

添加回答

举报

0/150
提交
取消
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号