第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

react中option標(biāo)簽如何確定selected?

react中option標(biāo)簽如何確定selected?

搖曳的薔薇 2018-12-19 18:19:19
我想在react中返回一組option,其中有一個(gè)option我想把他設(shè)置為selected,不知道如何實(shí)現(xiàn)。大致代碼render() {    let items = ['a', 'b', 'c', 'd']      .map((fileName) => (        if(fileName == 'd'){          <option key={fileName} value={fileName} selected>            {fileName}          </option>        }else{          <option key={fileName} value={fileName}>            {fileName}          </option>        }      ));    return (      <div>        <select          onChange={this.onChooseLocale.bind(this)}          defaultValue={Settings.get('locales', 'en-US')}        >        {items}        </select>      </div>    );  }不做判斷的話,直接寫let items = ['a', 'b', 'c', 'd']      .map((fileName) => (          <option key={fileName} value={fileName}>            {fileName}          </option>      ));但是加了 if else 就不行了。已經(jīng)搞定了~ 不用判斷if else, 只需要在option中加上value屬性,當(dāng)屬性和option的value相同時(shí),就會(huì)自動(dòng)顯示
查看完整描述

1 回答

  • 1 回答
  • 0 關(guān)注
  • 536 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)