【发布时间】:2019-03-06 03:28:56
【问题描述】:
下面是代码,基本上我试图根据用户输入制作一些下拉框,以建议适合他们情况的完美啤酒。我正在尝试添加下拉菜单,但我在第 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;
【问题讨论】:
-
我不知道反应语法,但你确定在
<Dropdown之后有;插入在Dropdown和option={...}之间
标签: javascript reactjs token unexpected-token