下面是代码,基本上我正在尝试根据用户输入制作一些下拉框,以建议适合他们情况的完美啤酒。我正在尝试添加下拉菜单,但我在第 11 行通过 const 得到了这个“意外令牌”。帮助将不胜感激,甚至更多关于如何制作下拉菜单并将它们与图像配对的见解?
What I would like, is to make 1 drop down bar that has a lift of about 10-15 beers that will correspond with an image when a beer from the list is selected
import React from "react";
import Dropdown from 'react-dropdown';
import 'react-dropdown/style.css';
const defaultOption = options[0];
<Dropdown options={options} onChange={this._onSelect} value={defaultOption} placeholder="Select an option"/>
const Form = props => (
<form onSubmit={props.getBeer}>
<input type="text" name="beerName" />
<button>Search</button>
</form>
);
const options = [
{ value: 'one', label: 'One' },
{ value: 'two', label: 'Two', className: 'myOptionClassName' },
{
type: 'group', name: 'group1', items: [
{ value: 'three', label: 'Three', className: 'myOptionClassName' },
{ value: 'four', label: 'Four' }
]
},
{
type: 'group', name: 'group2', items: [
{ value: 'five', label: 'Five' },
{ value: 'six', label: 'Six' }
]
}
]
export default Form;