React常用知识点

87 篇文章 0 订阅
10 篇文章 0 订阅

1、jsonResult - json展示

import { Tabs, Form, Input, Alert, Button, Spin } from 'antd';
import JSONResult from 'components/JSONResult';

class TestTab extends React.Component {
	...
	render(){
	 	const { testAccounts, testResult, resultLoading, attentionLoading } = this.state;
		return (
			<div className={styles.testResult}>
	          <div className={styles.result}>
	            <Spin spinning={resultLoading}>
	              <JSONResult result={testResult} />
	            </Spin>
	          </div>
	        </div>
		);
	}
}
export default TestTab;

JSONResult组件包含 JSONResult/index.js, JSONResult/index.less, JSONResult/theme.js 三个文件:
其中,JSONResult/index.js:

import PropTypes from 'prop-types';
import styles from './index.less';
import JSONTree from 'react-json-tree';
import theme from './theme';

function TestResult({ result }) {
  return (
    <div className={styles.testResult}>
      <div className={styles.inner}>
        {result ? (
          <JSONTree
            data={result}
            theme={theme}
            shouldExpandNode={() => {
              return true;
            }}
          />
        ) : (
          ''
        )}
      </div>
    </div>
  );
}
TestResult.propTypes = {
  result: PropTypes.object
};
export default TestResult;

JSONResult/index.less:

.testResult {
    .inner {
      height:500px;
      overflow: scroll;
      padding-left:10px;
    }
  }

JSONResult/theme.js:

const theme = {
    scheme: 'monokai',
    author: 'wimer hazenberg (http://www.monokai.nl)',
    base00: '#272822',
    base01: '#383830',
    base02: '#49483e',
    base03: '#75715e',
    base04: '#a59f85',
    base05: '#f8f8f2',
    base06: '#f5f4f1',
    base07: '#f9f8f5',
    base08: '#f92672',
    base09: '#fd971f',
    base0A: '#f4bf75',
    base0B: '#a6e22e',
    base0C: '#a1efe4',
    base0D: '#66d9ef',
    base0E: '#ae81ff',
    base0F: '#cc6633'
  };
  export default theme;

效果图:
在这里插入图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值