前端框架Aurelia
来源:互联网 发布:电脑里编程开发 编辑:程序博客网 时间:2024/04/28 00:59
1.Value Converter
Aurelia的value converter的改进:
- The Aurelia ValueConverter interface uses
toView
andfromView
methods, which make it quite clear which direction the data is flowing. This is in contrast to Xaml'sIValueConverter
, which usesConvert
andConvertBack
.Aurelia的value converter用toView和fromView方法来标识数据流方向。2.In Aurelia, converter parameters can be data-bound. This is something that was missing in Xaml and enables more advanced binding scenarios.转换的参数可以被数据绑定。3.Aurelia value converter methods can accept multiple parameters.Aurelia的值转换方法可以接受多参数。4.Multiple value converters can be composed using pipes (|
).多个值转换可以用 | 。
2.Simple Converters
http://aurelia.io/hub.html#/doc/article/aurelia/binding/latest/binding-value-converters/3Well, first we created a couple of value converters:DateFormatValueConverter
andCurrencyFormatValueConverter
. Each has atoView
method that the Aurelia framework will apply to model values before displaying them in the view. Our converters use the MomentJS and NumeralJS libraries to format the data.toView方法,aurelia框架在view上显示values前会先向ValueConverter申请model values。Next, we updated the view torequire
the converters so they can be used in the view. When requiring a resource such as a value converter, you supply the path to the resource in the require element'sfrom
attribute.要引入文件的意思咯。<require from="./date-format"></require><require from="./currency-format"></require>
When Aurelia processes the resource, it examines the class's metadata to determine the resource type (custom element, custom attribute, value converter, etc). Metadata isn't required, and in fact our value converters didn't expose any. Instead, we relied on one of Aurelia's simple conventions: export names ending with ValueConverter are assumed to be value converters. The convention registers the converter using the export name, camel-cased, with the ValueConverter portion stripped from the end.Aurelia有一个简单的约定,我们用ValueConverter来作为value converter文件名的结尾。
DateFormatValueConverter
registers asdateFormat
CurrencyFormatValueConverter
registers ascurrencyFormat
Finally, we applied the converter in the binding using the pipe |
syntax:
下面的代码是给value converter绑定变量,这样就是哪个value converter format 哪个变量。${currentDate | dateFormat} <br/>${netWorth | currencyFormat}
0 0
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia
- 前端框架Aurelia —— 路由Router
- 前端框架Aurelia——组件Component(一)
- 前端框架Aurelia——组件Component(二)组件生命周期
- 前端框架
- 前端框架
- Java环境配置
- UART 和 USART 有区别
- 用PHP SDK做支付宝APP支付(下单及验签)
- Spark on Mesos: 搭建Mesos的一些问题
- Java设计模式(一):单例模式,防止反射和反序列化漏洞
- 前端框架Aurelia
- 【游记】ZJOI2017 Day1 #3
- JDBC(PreparedStatement,sql注入)
- bzoj 4516: [Sdoi2016]生成魔咒 后缀数组
- HTML学习(II)
- 《计算机网络》第4章 介质访问控制子层
- 【编译工具】CMake【梳理】(编辑中)
- Spark实践的阶段性总结
- Codeforces 574C Bear and Poker【思维】