나는 React를 처음 사용하며 3 개의 선택 항목이있는 간단한 동적 양식을 만들려고합니다.하위 업데이트 선택
제 문제는 하위 선택 항목의 옵션은 상위 선택 항목에서 선택한 옵션에 따라 입력해야한다는 것입니다.
var MySelect = React.createClass({
getInitialState: function() {
return {
value: 'select'
}
},
change: function(event){
this.setState({value: event.target.value});
},
render: function(){
return(
React.createElement(
'div',
{ },
React.createElement(
'select',
{ id: this.props.id,
onChange: this.change,
value: this.state.value
},
React.createElement("option", null, "Yes"),
React.createElement("option", null, "No"),
this.props.title
),
React.createElement(
'select',
{ id: this.props.id,
onChange: this.change,
value: this.state.value
},
React.createElement("option", null, "Author1"),
React.createElement("option", null, "Author2"),
this.props.title
),
React.createElement(
'select',
{ id: this.props.id,
onChange: this.change,
value: this.state.value
},
React.createElement("option", null, "Book1"),
React.createElement("option", null, "Book2"),
this.props.title
)
));
}
});
그래서 우리는 예, 우리는 2 저자를 가지고 있고, 우리가 author1 선택하면 선택하면 - 우리는 BOOK1를 선택할 수 있습니다
여기 내 코드입니다.
author2를 선택하는 경우 book2 만 선택할 수 있지만 book1은 선택할 수 없습니다. 아니요를 선택하면 저자 또는 서적을 선택할 수 없습니다. 나는 국가와 무언가가 있어야한다고 생각하지만, 나는 여전히 문서에서 요점을 얻을 수 없습니다.
감사합니다. 예를 들어 몇 가지 코드를 제공해 주시겠습니까? 나는 주 (( – Jack
https://github.com/rajzshkr/componentWillReceiveProps - 이것은 문제를 도왔다. – Jack