日志查看
npm install react-syntax-highlighter --save
- 使用
import {FC} from 'ract';
import {PrismAsyncLight} from 'react-syntax-highlighter';
import json from 'react-syntax-highlighter/dist/esm/languages/prism/json';
import python from 'react-syntax-highlighter/dist/esm/languages/prism/python';
import {vscDarkPlus} from 'react-syntax-highlighter/dist/esm/styles/prism';
PrismAsyncLight.registerLanguage('python',python);
PrismAsyncLight.registerLanguage('json',json);
interface PropsType{
logInfo:string;
}
const TrainLog:FC<PropsType>={logInfo}=> {
return (
<div>
<PrismAsyncLight
language={'json'}
style={vscDarkPlus}
customStyle={{margin:0}} // 自定义样式
>
{logInfo}
</PrismAsyncLight>
</div>
)
}
export default TrainLog:FC;