-
Notifications
You must be signed in to change notification settings - Fork 93
quickstart
quirkyvar edited this page May 19, 2018
·
4 revisions
$ npm install --save noform
import Form, { FormItem, FormCore } from 'noform'; // 引入
const Input = ({ value = '', status }) => { // 模拟input
if (status === 'edit') {
return <input value={value} />
} else {
return `presenting preview val: ${value}`
}
};
class App extends React.Component {
componentWillMount () => { // 初始化表单核心
window.core = this.core = new FormCore();
}
render() { // 注入核心
return <Form core={this.core}>
<FormItem name="username" label="username"><Input /></FormItem>
</Form>
}
}
现在到控制台中使用core感受一下
core.setValue('username', 'john');
core.setStatus('username', 'preview');