1

我正在 Wakanda 中创建一个自定义小部件。

这个小部件必须接收孩子。我怎样才能改变这个小部件,以便我可以将其他小部件放入其中?

4

2 回答 2

1

为了能够包含小部件,使用 API 版本 2 的自定义小部件必须继承容器行为

YourWidget.inherit(WAF.require('waf-behavior/layout/container'));

一个示例是 WAF 中包含的 Container 小部件。

WAF.define('Container', ['waf-core/widget'], function(widget) {
  "use strict";

  var Container = widget.create('Container', {
    init: function() {
        this.removeClass('well well-sub');
        if($(this.node).closest('.well').length > 0){
            this.addClass('well-sub');
        }
        else{
            this.addClass('well');
        }
    }
  });
  Container.inherit(WAF.require('waf-behavior/layout/container'));

  return Container;
});

容器小部件源代码

于 2016-08-22T08:53:16.187 回答
0

您的小部件应继承自 'waf-behavior/layout/container' 。
这部分文档包含您的需要: http: //livedoc.wakanda.org/Widgets-Instance-API/Container.201-1055278.en.html

于 2016-08-22T09:30:34.280 回答