加载 KLLoading
基本形式
<kl-button on-click="{this.showLoading()}" title="显示加载,2秒后隐藏" />
<kl-loading visible={visible} />
var component = new NEKUI.Component({
template: template,
config: function(data) {
data.visible = false;
},
showLoading: function() {
this.data.visible = true;
setTimeout(function() {
this.$update('visible', false);
}.bind(this), 2000);
}
});
嵌入文档流
<kl-button on-click="{visible = !visible}" title="{visible ? '隐藏加载' : '显示加载'}" />
<p>
<kl-loading visible={visible} static />
</p>
var component = new NEKUI.Component({
template: template,
config: function(data) {
data.visible = false;
}
});
指定嵌入的父级元素
<kl-button on-click="{this.show()}" title="显示加载,2秒后隐藏" />
var component = new NEKUI.Component({
template: template,
config: function(data) {
},
show: function() {
var loading = new NEKUI.KLLoading({
data: {
visible: true,
el: '#main'
}
});
setTimeout(function() {
loading.destroy();
}, 2000);
}
});
API
KLLoading
KLLoading
Param | Type | Default | Description |
---|
[options.data] | object | | = 绑定属性 |
[options.data.static] | boolean | false | => 是否嵌入文档流 |
[options.data.disabled] | boolean | false | => 是否禁用, 禁用后调用show和hide则无效 |
[options.data.visible] | boolean | false | => 是否显示 |
[options.data.class] | string | | => 补充class |
[options.data.el] | string | | => 设置对话框要嵌入的父级元素,默认为document.body |
.show() 显示组件method
.hide() 隐藏组件method
.loadingstatic property
Param | Description |
---|
loading | 内部静态实例, 使用NEKUI.KLLoading的静态方法时,内部使用的是这个实例 |
.showstatic method
.hidestatic method