|
|
@ -194,6 +194,17 @@ export default class TPManswer extends Component {
|
|
|
|
newAnswers[index] = newAnswer
|
|
|
|
newAnswers[index] = newAnswer
|
|
|
|
this.setState({ answers: newAnswers})
|
|
|
|
this.setState({ answers: newAnswers})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
answerOnChange = (val, index) => {
|
|
|
|
|
|
|
|
// if (!this.state.answers[index]) {
|
|
|
|
|
|
|
|
// // 1、2、3删除2会走到这里
|
|
|
|
|
|
|
|
// return;
|
|
|
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
const newAnswer = Object.assign({}, this.state.answers[index])
|
|
|
|
|
|
|
|
newAnswer.contents = val
|
|
|
|
|
|
|
|
const newAnswers = this.state.answers.slice(0)
|
|
|
|
|
|
|
|
newAnswers[index] = newAnswer
|
|
|
|
|
|
|
|
this.setState({ answers: newAnswers})
|
|
|
|
|
|
|
|
}
|
|
|
|
addAnswer = () => {
|
|
|
|
addAnswer = () => {
|
|
|
|
const newAnswers = this.state.answers.slice(0)
|
|
|
|
const newAnswers = this.state.answers.slice(0)
|
|
|
|
newAnswers.push({
|
|
|
|
newAnswers.push({
|
|
|
@ -210,6 +221,10 @@ export default class TPManswer extends Component {
|
|
|
|
newanswers.splice(index,1)
|
|
|
|
newanswers.splice(index,1)
|
|
|
|
this.setState({
|
|
|
|
this.setState({
|
|
|
|
answers:newanswers
|
|
|
|
answers:newanswers
|
|
|
|
|
|
|
|
}, () => {
|
|
|
|
|
|
|
|
for(let i = index; i < newanswers.length; i ++) {
|
|
|
|
|
|
|
|
this.refs[`md${i}`].setValue(newanswers[i].contents)
|
|
|
|
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
render() {
|
|
|
|
render() {
|
|
|
@ -316,7 +331,8 @@ export default class TPManswer extends Component {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div className="mt10">
|
|
|
|
<div className="mt10">
|
|
|
|
<span>参考答案:</span>
|
|
|
|
<span>参考答案:</span>
|
|
|
|
<TPMMDEditor ref={`md${index}`} mdID={index} initValue={answer.contents}></TPMMDEditor>
|
|
|
|
<TPMMDEditor ref={`md${index}`} mdID={index} initValue={answer.contents}
|
|
|
|
|
|
|
|
onChange={(val) => this.answerOnChange(val, index)}></TPMMDEditor>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|