鸬鹚洲 发表于 2017-9-6 11:09:18

可继承的前端开发框架 Intact v2.0 发布

var Layout = Intact.extend({  
    template: '<div>\
  
      <header>\
  
            <b:header>Extendable and Reactive Component</b:header>\
  
      </header>\
  
      <div>\
  
            <b:body>\
  
                <div class=&quot;count&quot;>{self.get(&quot;count&quot;)}</div>\
  
            </b:body>\
  
      </div>\
  
    </div>',
  
    defaults: function() {
  
      return {count: 0};
  
    }
  
});
  

  
var Page = Layout.extend({
  
    template: '<t:parent>\
  
      <b:body>\
  
            {parent()}\
  
            <button class=&quot;button&quot;\
  
                ev-click={self.add.bind(self)}\
  
            >Click me!</button>\
  
      </b:body>\
  
    </t:parent>',
  
    add: function() {
  
      this.set('count', this.get('count') + 1);
  
    }
  
});
  

  
Intact.mount(Page, document.getElementById('app'));
页: [1]
查看完整版本: 可继承的前端开发框架 Intact v2.0 发布