基于Weaver Component二次封装组件的使用说明
Authority组件
- 实例化AuthorityStore
@observable authorityStore = new AuthorityStore(api.getHasRight);
- 引入Authority组件,并传入authorityStore
import {
Authority,
} from '../../public/valhalla/components/index.js';
render() {
const {
store
} = this.props, {
authorityStore,
} = store;
return (
<Authority store={authorityStore}>
...
</Authority>
)
}
Top组件
- 实例化TopStore
@observable topStore = new TopStore(api.getRightMenu, this);
- 定义组件的loading属性
//一般获取tableStore的loading属性作为页面的加载状态
get topLoading() {
const {
loading
} = this.tableListStore.tableStore;
return loading;
}
- 定义页面上按钮、菜单的状态
//数组中的loading一一对应页面上按钮、菜单的状态
get rightMenuStates() {
const {
loading,
} = this.tableListStore.tableStore;
return [loading, loading, loading, loading];
}
- 其他配置
//设置页面标题
get topConfig() {
return {
title: getLabel('505619', "假期余额设置")
}
}
- 假如页面上需要【有无账号】的图标开关按钮
import {
AccountIcon
} from '../public/valhalla/components/index.js';
get otherTopButtons() {
return [<AccountIcon isShow={this.isNoAccountShow} onClick={this.handleAccountIconClick}/>]
}
- 引入Top组件,并传入topStore
import {
Top,
} from '../../public/valhalla/components/index.js';
render() {
const {
store
} = this.props, {
topStore,
} = store;
return (
<Top store={topStore}>
...
</Top>
)
}