【翻译】Knockout 2.1版本发布&新特性一览
2012-05-09 15:07
323 查看
Knockout.JS 2.1 现在已经发布了! 源代码可以在这里下载here. 这个版本主要是对2.0版本进行了一些bug修复,以及性能优化。
下面是主要的新特性:
CommonJS and AMD support 【支持异步定义组件,以及配合requireJS异步加载viewModel、进行绑定】
Great performance improvements to templating - use cloned DOM nodes when possible rather than parsing strings into elements. 【模板的性能优化:尽可能的使用复制DOM节点的方式而不是往DOM中插入文档标记的方式来渲染模板】
Support for custom container-less bindings 【支持编写能够识别虚拟节点的自定义绑定(也就是支持<!—ko: yourBindName -->标记)】
Ability to extend the binding context in a custom binding 【支持对自定义binding的绑定上下文进行扩充,比如:在父元素的绑定可以应用到下面所有的子元素!】
Computed observables no longer can recursively evaluate themselves【computed属性不再会递归的修改自身】
Better support for using a single instance of KO between documents - you can now pass an instance of KO between documents and have bindings work properly across the documents. Previously the computed observables associated with bindings would dispose themselves when outside of the original document as they believed they were no longer part of the DOM. 【对多个document共享一个viewModel实例提供了更好的支持,现在可以在多个文档之间传递viewModel对象,并使他们生效。】
Numerous other bug and performance fixes 【一些其他bug的修复和性能的优化】
如有不妥的地方,欢迎拍砖!
下面是主要的新特性:
CommonJS and AMD support 【支持异步定义组件,以及配合requireJS异步加载viewModel、进行绑定】
Great performance improvements to templating - use cloned DOM nodes when possible rather than parsing strings into elements. 【模板的性能优化:尽可能的使用复制DOM节点的方式而不是往DOM中插入文档标记的方式来渲染模板】
Support for custom container-less bindings 【支持编写能够识别虚拟节点的自定义绑定(也就是支持<!—ko: yourBindName -->标记)】
Ability to extend the binding context in a custom binding 【支持对自定义binding的绑定上下文进行扩充,比如:在父元素的绑定可以应用到下面所有的子元素!】
Computed observables no longer can recursively evaluate themselves【computed属性不再会递归的修改自身】
$indexis available in
foreachscenarios from the binding context. There is no longer a need for workarounds like storing an index as a property of your data items. Note that
$indexis an observable, so it needs to be reference using
$index()in expressions. 【这个非常有用,在foreach绑定的时候直接可以使用$index来绑定一个序号,并且这个变量是observable的,也就是说当集合元素数量改变的时候,index会自动更新】
$parentContextis available from the binding context as well. While,
$parentcontains the actual data from one scope level up,
$parentContextcontains the actual binding context (
$data,
$parent,
$parents,
$root, etc.) of the parent. 【
$parentContext属性被加入到绑定上下文,这个属性里包含其他绑定上下文对象:parent,root等】
ko.isComputedis a helper function that was added to determine if a value is a computed observable or not. 【添加了一个helper方法,用于判断一个属性是不是computed属性】
ko.toJSONnow passes its arguments on to
JSON.stringifyafter calling
ko.toJS. This makes creating a handy “debug” section even easier
<pre data-bind="text: ko.toJSON($root, null, 2)"></pre>and this can be used to include only certain properties in the converted JSON like
ko.toJSON(person, ['firstName', 'lastName']). This seems even more flexible in many cases than the approach that I mentioned here. 【ko.toJSON方法现在可以传入几个参数,来控制只序列化model中的某几个属性,这使得程序调试更加方便了】
Better support for using a single instance of KO between documents - you can now pass an instance of KO between documents and have bindings work properly across the documents. Previously the computed observables associated with bindings would dispose themselves when outside of the original document as they believed they were no longer part of the DOM. 【对多个document共享一个viewModel实例提供了更好的支持,现在可以在多个文档之间传递viewModel对象,并使他们生效。】
Numerous other bug and performance fixes 【一些其他bug的修复和性能的优化】
如有不妥的地方,欢迎拍砖!
相关文章推荐
- xmake v2.1.5版本正式发布,大量新特性更新
- [翻译] Ext JS 6.5 和 Sencha Cmd 6.5 GA(一般可用) 版本发布
- JDK版本新特性介绍&JDK1.6
- JSP 2.1和JSF 1.2规范发布预览版本
- ECharts 大版本 4.0 正式发布:带来 8 项全新“黑科技”特性
- 【翻译】Unity2017.2.0f3 版本发布说明
- 手把手引进门之 ASP.NET Core & Entity Framework Core(官方教程翻译版 版本3.2.5)
- ALinq BUG & 版本发布
- 翻译:Knockout 快速上手 - 4: 你需要知道的顶级特性
- WordPress 2.1 'Ella' 正式发布
- 【翻译】Ext JS 6早期访问版本发布
- iOS开发 - 第05篇 - 项目 - 03 - 版本新特性 & OAuth授权
- [翻译] .NET Core 2.1 Preview 1 发布
- JSP 2.1和JSF 1.2规范发布预览版本
- Python有道翻译2.1版本爬虫实现
- 【翻译】Ext JS 6早期访问版本发布
- Jacket for Matlab 2.1版本发布
- Redis pub/sub机制在实际运用场景的缺陷&&模拟JMS消息发布订阅的持久化特性
- 最新版本的Hive 0.13发布,增加ACID特性
- C# AndrewUtil.dll 在小博中发布&分享(翻译组件)