[英]Backbone.js requires json2.js?
From the site: 从站点:
Backbone's only hard dependency is either Underscore.js ( > 1.4.3) or Lo-Dash.
Backbone唯一的硬依赖性是Underscore.js(> 1.4.3)或Lo-Dash。 For RESTful persistence, history support via Backbone.Router and DOM manipulation with Backbone.View, include json2.js, and either jQuery ( > 1.4.2) or Zepto.
为了实现RESTful持久性,可通过Backbone.Router支持历史记录,并使用Backbone.View进行DOM操作,包括json2.js以及jQuery(> 1.4.2)或Zepto。
Why is json2.js mentioned? 为什么提到json2.js? I have run my app in ie7-9 among other browsers without requiring this file and it works.
我已经在其他浏览器中的ie7-9中运行了我的应用,而无需此文件,并且它可以工作。 Is this a performance thing?
这是表演吗?
json2.js provides JSON.parse
and JSON.stringify
functions, which Backbone depends on. json2.js提供了Backbone依赖的
JSON.parse
和JSON.stringify
函数。 They've been included in browsers for a while but it's probably listed in case your environment doesn't include it, or you want a consistent implementation in your app. 它们已经被包含在浏览器中已有一段时间了,但是如果您的环境不包含它们,或者您想要在应用程序中实现一致的实现,则可能已列出它们。
That script adds JSON functionality to older browsers that will look just like native functionality that exists in newer browsers 该脚本向较旧的浏览器添加了JSON功能,就像在较新的浏览器中存在的本机功能一样
https://github.com/douglascrockford/JSON-js https://github.com/douglascrockford/JSON-js
As the other answers have suggested, you only need to download and include the "manual" JSON library if you need to support older browsers; 正如其他答案所建议的那样,仅在需要支持较旧的浏览器时才需要下载并包括“手动” JSON库。 otherwise your browser will have it built in (which is how you saw Backbone work without issue).
否则,您的浏览器将内置它(这是您看到Backbone正常工作的方式)。
For the exact list of which browsers have/don't have JSON built in, see: http://caniuse.com/#feat=json 有关哪些浏览器内置/不内置JSON的确切列表,请参见: http : //caniuse.com/#feat=json
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.