【发布时间】:2023-04-10 23:59:01
【问题描述】:
我对 js 很陌生,所以我希望有人能给我一个关于这个问题的想法。我的解决方案非常糟糕,但我想不出一个好的解决方案。我也不知道如何在渲染中添加 if-else 语句。有 6 个按钮,每个按钮都是 json-schema 的名称(最好有一个表格而不是按钮,但我在使用 tableview 时总是出错)。 我想在用户单击按钮时显示 json-schema,以便用户可以提交 json 文件。
import React, { Component, useState } from 'react';
import { Row, Col } from 'react-bootstrap';
import { withTheme } from '@rjsf/core';
import schema1 from '../schemas/schema1.json';
import schema2 from '../schemas/schema2.json';
import { Datagrid, TextField, EditButton, DeleteButton } from 'react-admin';
class MyApp extends Component {
constructor(props) {
super(props);
this.clickme = this.clickme.bind(this);
}
ToggleGroup() {
const theme = {
blue: {
default: '#3f51b5',
hover: '#283593',
},
pink: {
default: '#000000',
hover: '#ad1457'
}
}
return (<div>
{types.map(type => (
<Col>
<Col>
<Button
active={active === type}
>{type}</Button>
</Col>
</Col>
))}
<Col>
<Form
schema={schema1}
/>
</Col>
</div>
);
}
render() {
return (
<>
<Col>
<Col>
<text>
List of schemas
</text>
</Col>
</Col>
<this.ToggleGroup />
</>
);
}
}
export default MyApp;
【问题讨论】:
标签: reactjs json jsonschema