我正在使用材质 UI下拉组件,并且仅在用户填写所有表单并提交表单时才尝试运行回调函数。在回调函数上,我打算收集所有表单字段并生成 url 以调用 api。
我的问题是我不能像#560中所述的解决方案那样使用 onChange,因为我只想在用户单击提交按钮时收集所有详细信息。奇怪的是,目前,我能够获得所有其他表单元素的值,如滑块、使用 material-ui 但只有下拉菜单的文本字段似乎不起作用。
我的回调函数:
handleFilter: function(event){
event.preventDefault();
var location = this.refs.location.getValue();
var posted_date = this.refs.posted_date.getValue();
var radius = this.refs.distance.getValue();
var salary = this.refs.salary.getValue();
var jobtype = this.refs.jobtype.getValue();
console.log(jobtype);
}
在上面的函数“location,posted_date,radius,salary”中返回值,但恰好是下拉列表的“jobtype”似乎没有返回任何值。它在控制台中返回此错误:“Uncaught TypeError: this.refs.jobtype.getValue is not a function”
这是我的下拉组件:
<DropDownMenu menuItems={menuItems} ref="jobtype" />