我正在尝试让我的自定义表单域与 NextJS 很好地配合。但水分似乎有问题。
这是我的网络组件:
@Component({
tag: 'test-checkbox',
shadow: false,
})
export class TestCheckbox {
@Prop() name: string;
@Prop() value: boolean;
@Prop() label: string;
@Prop() innerValue: string;
render() {
const { value, name } = this;
return (
<div>
<label htmlFor={this.name}>{this.label}</label>
<input type="checkbox" name={name} id={name} checked={!!value} />
</div>
);
}
}
Run Code Online (Sandbox Code Playgroud)
我正在使用 Stencil ReactJS 包装器,因此 NextJS 中的代码将如下所示:
const Form = () => {
const formRef = useRef();
const handleInput = (e) => {
///
};
const handleSubmit = (e) => { …Run Code Online (Sandbox Code Playgroud)