2016-04-30 20 views
0

私はこのような何かしようとしている:react-boostrap multi selectで選択した値を設定する方法は?

<FormControl componentClass="select" multiple value="['other1', 'other2']"> 
    <option value="other1">other1</option> 
    <option value="other2">other2</option> 
    <option value="other3">other3</option> 
    <option value="other4">other4</option> 
    <option value="other5">other5</option> 
</FormControl> 

をしかし、私は構文が正しく取得できない、そしてその右のアプローチならば、実際に確認していないことができます。

答えて

0

私はここで答えを発見:https://facebook.github.io/react/docs/forms.html

注:あなたは selectタグで複数のオプションを選択できるように、value属性に配列を渡すことができます。

私の元の例から、これはそれを行うための正しい方法である:

<FormControl componentClass="select" multiple value={['other1', 'other2']}> 
    <option value="other1">other1</option> 
    <option value="other2">other2</option> 
    <option value="other3">other3</option> 
    <option value="other4">other4</option> 
    <option value="other5">other5</option> 
</FormControl> 
関連する問題