UNPKG

qm-bus

Version:

千米公有云业务组件库

64 lines (53 loc) 1.59 kB
/** * @author gcy[of1518] * @date 16/09/30 * * @description Table service加持 */ import React, { Component } from 'react' const noop = () => undefined export default class QMDataViewCore extends Component { static defaultProps = { netUrl: '', //异步请求url netHost: '', //请求域 netPre: undefined, net: undefined, netPost: undefined, hash: '', // //private init: noop, initial: noop, onFetch: noop, onRefresh: noop, onCurrentRefresh: noop, manual: false, //是否初始化 } constructor(props) { super(props) } componentWillMount() { let { netUrl, netHost, init, netPre, net, netPost, defaultDataFilter } = this.props init({ netUrl, netHost, netPre, net, netPost, dataFilter: defaultDataFilter }) } componentWillReceiveProps(nextProps) { if (nextProps.hash != this.props.hash) { let { onFetch, netUrl, netHost, initial, netPre, net, netPost, hash, manual } = this.props if (!!netUrl && !manual) { //如果配置异步请求url则开始发送请求 this.props.onRefresh(true) } } } render() { let { className } = this.props return <div className={className}>{this.props.children}</div> } componentDidMount() { let { onFetch, netUrl, netHost, initial, netPre, net, netPost, hash, manual } = this.props initial({ hash }) if (!!netUrl && !manual) { //如果配置异步请求url则开始发送请求 onFetch({ url: netUrl || '', host: netHost || '', netPre, net, netPost, clearFilter: false }) } } }