React JSON形式的自定义选择组件

时间:2018-06-28 14:35:16

标签: javascript forms reactjs

嗨,我正在使用mozilla react json表单,想要向json表单添加自定义选择组件。,我阅读了文档,但无法添加新组件

我的代码

import React, { Component } from 'react';


import { render } from 'react-dom';

import Form from 'react-jsonschema-form';

const schema = {
  title: 'test',
  type: 'object',
  required: ['name'],
  properties: {
    name: { type: 'string', title: 'Name' },
    email: { type: 'string', title: 'Email' },
  },
};


const log = type => console.log.bind(console, type);


class App extends Component {
  render() {
    return (
      <div className="App">
        <Form schema={schema} onSubmit={log('submitted')} onError={log('errors')}/>
      </div>
    );
  }
}

export default App;

我选择的组件是:

<select>
 <option>1</option>
 <option>2</option>
 <option>3</option>
</select>

0 个答案:

没有答案