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

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

在 React Native-JavaScript 中將布爾值轉(zhuǎn)換為字符串

在 React Native-JavaScript 中將布爾值轉(zhuǎn)換為字符串

米琪卡哇伊 2023-03-03 10:19:22
所以,我在做一個(gè) React Native 項(xiàng)目,我有一個(gè)這樣的復(fù)選框:      import ARCheckBox from '@react-native-community/checkbox';      .............      <View style={styles.row}>      <Text style={styles.label}>Insured Interest</Text>         <Text>Section IV - AutomobileLiability</Text>         <ARCheckBox          value={this.state.arCBValue3}          onValueChange={value =>            this.setState({              arCBValue3: value,            })          }        />      </View>這是我的 .js 輸出:import { style } from "./../../../reports/ARCssPdf";export const arGenerateFileHtml = values => {  return`  ${style}  ${generateNameSectionHtml(values)}`;};const generateNameSectionHtml = name =>`<html><head></head>    <br/><body>  <div>      <table style="width:450px">      <tr>      <td> Section IV - AutomobileLiability</td>      <th> : </th>      <th> ${name.arCBValue3}</th> //This is the output      </tr>  </table></div></body></html>`但我得到的結(jié)果是這樣的:Section IV - AutomobileLiability : true/false雖然我想要的結(jié)果是這樣的:Section IV - AutomobileLiability : Yes/No我如何獲得該結(jié)果?我試過(guò)使用replaceFunction 將 true/false 替換為 Yes/No,但它不起作用。我知道我必須先做一個(gè)函數(shù),但我不知道怎么做。任何幫助將不勝感激。謝謝
查看完整描述

2 回答

?
慕桂英546537

TA貢獻(xiàn)1848條經(jīng)驗(yàn) 獲得超10個(gè)贊

你試過(guò)了嗎:

   <th> ${name.arCBValue3 ? 'Yes':'No'}</th>


查看完整回答
反對(duì) 回復(fù) 2023-03-03
?
子衿沉夜

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超3個(gè)贊

import {

  style

} from "./../../../reports/ARCssPdf";


export const arGenerateFileHtml = values => {

  return `

  ${style}

  ${generateNameSectionHtml(values)}`;

};

const replacer = value => value ? "Yes" : "No"

const generateNameSectionHtml = name =>

  `<html>

<head>

</head>

    <br/>

<body>

  <div>

      <table style="width:450px">

      <tr>

      <td> Section IV - AutomobileLiability</td>

      <th> : </th>

      <th> ${replacer(name.arCBValue3)}</th> //This is the output

      </tr>

  </table>

</div>

</body>

</html>`

<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>

<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>


查看完整回答
反對(duì) 回復(fù) 2023-03-03
  • 2 回答
  • 0 關(guān)注
  • 185 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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