Reactjs 使用react jsonschema表单字段事件
我有一个简单的模式来生成表单。我想在鼠标悬停时对字段执行一些操作。但我不知道如何将鼠标移到所有字段。通过阅读,我发现表单字段有一些事件。 -表单字段模糊事件 -形成现场焦点事件 不过,他们没有任何例子。请帮助我了解在哪里可以设置鼠标悬停事件? 这是我的模式:Reactjs 使用react jsonschema表单字段事件,reactjs,react-jsonschema-forms,Reactjs,React Jsonschema Forms,我有一个简单的模式来生成表单。我想在鼠标悬停时对字段执行一些操作。但我不知道如何将鼠标移到所有字段。通过阅读,我发现表单字段有一些事件。 -表单字段模糊事件 -形成现场焦点事件 不过,他们没有任何例子。请帮助我了解在哪里可以设置鼠标悬停事件? 这是我的模式: "schema": { "type":"object", "properties":{ "request": {
"schema":
{
"type":"object",
"properties":{
"request": {
"type": "object",
"properties": {
"requester": {
"type": "string"
},
"requestDate": {
"type": "integer"
},
"detailList": {
"type": "array",
"items": {
"id": "urn:jsonschema:com:fanap:demo:entity:ItemRequestDetail",
"type": "object",
"properties": {
"item": {
"id": "urn:jsonschema:com:fanap:demo:entity:ItemClass",
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
"requestedAmount": {
"type": "number"
}
}
}
},
"description": {
"type": "string"
},
"state": {
"id": "urn:jsonschema:com:fanap:demo:entity:CategoryElement",
"type": "object",
"properties": {
"name": {
"type": "string"
}
}
},
}
},
"processResult": {
"type": "object",
"properties": {
"notificationMessage": { "type": "string" }
}
}
}
}
这是我用来显示生成表单的组件:
class JsonFormWrapper extends React.Component<PropsT> {
render() {
return (
<React.Fragment>
{this.props.jsonResponse ? (
<Form
schema={this.props.jsonResponse.schema}
uiSchema={this.props.jsonResponse.uiSchema}
/>
) : null}
</React.Fragment>
);
}
}
export default JsonFormWrapper;
类JsonFormWrapper扩展了React.Component{
render(){
返回(
{this.props.jsonResponse(
):null}
);
}
}
导出默认JsonFormWrapper;
如何为所有元素设置鼠标悬停?
我真的很感激你能提供的任何帮助 可能是一个黑客解决方案,但您可以利用它定义自定义事件,如鼠标悬停。如果这样做有效,您必须定义一次,而不是对每个输入字段重复它在鼠标悬停事件上您到底想做什么?我认为这并不重要,但我想在每个元素上显示一些控制按钮,使鼠标悬停。我认为它们不提供鼠标悬停事件功能。您可以创建一个自定义小部件,并将鼠标悬停事件添加到该小部件中。如果您需要这方面的代码片段,我可以帮助您找到好的解决方案,但我有几个组件,jsonSchema默认提供了这些组件。例如,我有复选框、文本区域、文本、字段集等。。。。我想在它们上面显示控制按钮。正如您所说,我应该为所有这些组件编写自定义小部件。你认为这是对的吗?如果我将此事件添加到所有react jsonSchema现有小部件中,然后使用它,可能会更好。我错了吗?