React-Materialize单选按钮无法正常工作

时间:2019-06-06 07:17:34

标签: reactjs react-material

是ReactJ的新功能,并实现了实现。我在组件中通过react-materialize创建了两个输入元素类型Radio。两者都在DOM中呈现。

我单击第一个单选选项并触发onChange事件。单击后,第一次单击时未选择第二个选项,但第二次单击时工作正常。单击任何选项后,两者均不会触发事件。

“反应”:“ ^ 16.5.2” “ react-materialize”:“ ^ 2.4.8”,

此问题与该解决方案相同,并尝试使用该解决方案,但是无法正常工作https://github.com/react-materialize/react-materialize/issues/422

import React, {Component} from 'react'; 
import {Input} from 'react-materialize';
class Section extends Component {
    render() {
         return (
           <div className="row">
                {
                   this
                    .props
                    .options
                    .map((option, index) => (
                        <div key={index} className="col s6">
                            <Input
                                type="radio"
                                name="report"
                                className="with-gap"
                                value={option.value}
                                checked = {this.props.selected}
                                key={index}
                                onChange={(e)=>console.log(e.target.value)}
                                label={option.label}/>
                        </div>
                    ))
            }
        </div>
    );
}

}

我希望第一次单击时应选择两个单选选项的输出,并在所有单击时调用onChange。请纠正我犯了什么错误。

0 个答案:

没有答案
相关问题