答案 0 :(得分:0)
更改
中的代码 <select size={20} onChange={this.handleSelectListChange}>
到
<select size={20} onChange={this.handleSelectListChange.bind(this)}>
答案 1 :(得分:0)
它正常工作。
import { Component } from "react";
import React from "react";
class TestList extends Component {
handleSelectListChange = event => {
console.log("CLICKED " + event.target.value);
};
getList = () => {
let options = [];
for (let i = 0; i < 10; i++) {
options.push(<option key={i} value={i}>{"ITEM " + i}</option>);
}
return (
<select size={20} onChange={this.handleSelectListChange}>
{options}
</select>
);
};
render = () => {
let list = this.getList();
return (
<div>{list}</div>
);
};
}
export default TestList;