发布于 2016-05-26 23:26:33 | 175 次阅读 | 评论: 0 | 来源: 网友投递
RegularJS JavaScript MVC 框架
regularjs是一个基于字符串模板的用于创建数据驱动的组件的类库, 相较于其它同类的基于字符串的模板引擎比如(mustache), regularjs在compile之后数据和dom仍然保持联系, 所以也称之为'live template engine'.
RegularJS 0.4.4 发布了,更新了以下部分 :
重要度排序
1.默认extend不再预解析模板, 这个可能在组件数量很大的情况下并且使用类似webpack的整体打包工具时,会引入不必要的组件解析成本。 解析默认放置在实例化阶段, 并且每个组件的模板只会被解析一次。不过你仍然可以通过Regular.config来控制它
Regular.config({
PRECOMPILE: true})
2.增加了两个事件 $afterConfig, $afterInit, 使得在使用mixin时,可以更好的插入到组件逻辑中,具体顺序请看testcase
it('feature #82', function(){
+ var i = 0;
+ var mixins = {
+ events: {
+ $afterConfig: function(){
+ i++;
+ expect(i).to.equal(3)
+ },
+ $config: function(){
+ i++;
+ expect(i).to.equal(1)
+ },
+ $init: function(){
+ i++;
+ expect(i).to.equal(4)
+
+ },
+ $afterInit: function(){
+ i++;
+ expect(i).to.equal(6)
+ }
+ }
+ }
+
+ var Component = Regular.extend({
+ config: function(){
+ i++;
+ expect(i).to.equal(2)
+ },
+ init: function(){
+ i++;
+ expect(i).to.equal(5)
+ }
+ }).implement(mixins)
+
+ new Component();
+
+ expect(i).to.equal(6);
+ })
初始化时, 父组件不再强制将自己的数据同步给子
3.初始化时, 父组件不再强制将自己的数据同步给子组件,这个允许子组件在config中准备自己的数据后,同步给父组件