gpt4 book ai didi

javascript - 如何定义 Wakanda 自定义小部件 child ?

转载 作者:行者123 更新时间:2023-11-27 22:36:16 25 4
gpt4 key购买 nike

我正在瓦坎达创建一个自定义小部件。

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

最佳答案

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

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

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

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;
});

Container widget source code

关于javascript - 如何定义 Wakanda 自定义小部件 child ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39069750/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com