加载器组件。
import React, {Component} from 'react';
import {Loading, Button} from 'hana-ui';
/**
* @en
* Base
*
* hana provide three mode to show the loading.
* Press button to show `Loading`, it will hide in 5 seconds.
*
* @cn
* 基础
*
* hana 提供了三种模式去显示加载器。
* 点击按钮显示loading,5秒后停止loading。
*/
export default class ExampleBase extends Component {
state = {
show: false,
mode: 'queue'
}
startLoading = (mode) => {
this.setState({show: true, mode});
setTimeout(
() => this.setState({show: false}),
5000
);
}
render() {
return (
<div>
<Button
type="primary"
onClick={() => this.startLoading('queue')}
>
queue
</Button>
<br />
<br />
<Button
type="primary"
onClick={() => this.startLoading('rotate')}
>
rotate
</Button>
<br />
<br />
<Button
type="primary"
onClick={() => this.startLoading('image')}
>
image
</Button>
{this.state.show && <Loading mode={this.state.mode} image={'/demo/static/images/himawari.png'} />}
</div>
);
}
}
hana 提供了三种模式去显示加载器。
点击按钮显示loading,5秒后停止loading。
属性名 | 类型 | 默认值 | 说明 |
---|---|---|---|
mode | enum: 'rotate' 'queue' 'image' |
'queue' | 加载器的三种模式 |
content | node | 'loading...' | 加载器的内容 |
icon | node | 当mode 为“rotate”时,加载器的图标 |
|
icons | arrayOf | [ |
当mode 为“queue”时,加载器的图标们 |
image | string | '' | 当mode 为“image”时,加载器使用的图片 |
wrapStyle | object | 加载器的底部蒙版的style |
|
style | object | 加载器的style |
|
contentStyle | object | 加载器的内容的style |
|
className | string | 加载器的class |
未在文档中说明的属性将会被自动加到根元素或form元素上。