我在React JS应用程序中使用了下拉菜单,但是onChange事件没有触发
我的代码如下:
import React from "react";
import PropTypes from "prop-types";
import Dropdown from 'react-dropdown';
const options = [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two', className: 'myOptionClassName' },
];
class WebDashboardPage extends React.Component {
constructor(props) {
super(props);
this.state = {}
}
quan = (event)=> {
console.log("Option selected:");
this.setState({ value: event.target.value });
};
render() {
return(
<b><Dropdown className="dropdownCss" options={options} onChange={e =>
this.quan(e.target.value)} /></b>
);
}
当我点击下拉菜单中的项目时,会显示错误。
"TypeError: Cannot read property 'quan' of undefined"
我是React的新手,谢谢您提前的帮助。