0

下面是代码,基本上我正在尝试根据用户输入制作一些下拉框,以建议适合他们情况的完美啤酒。我正在尝试添加下拉菜单,但我在第 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;
4

1 回答 1

0
<Dropdown; options={options}, onChange={this:_onSelect}, value={defaultOption}, placeholder="Select an option">Dropdown>

正如 Yashwardhan Pauranik 指出的那样,删除 ; 在<Dropdown; 并关闭结束下拉标签?

于 2019-03-06T03:41:42.330 回答