如何從react-phone-number-input包中的選擇選項中洗掉國際選項?我試圖將這些國家/地區限制為六個。我已經添加了defaultCountry和countries道具,但它仍然允許輸入其他國家的電話號碼。這是我的使用方法:
<PhoneInput
placeholder={placeholder}
name={name}
value={value}
onChange={onValueChange}
onBlur={handleInputBlur}
onFocus={handleInputFocus}
defaultCountry={country}
countries={["NG", "MG", "SC", "KM", "BW", "MR"]}
/>
以下是它如何顯示包含但未在道具中指定的國際選項:

如何洗掉國際選項。
uj5u.com熱心網友回復:
將國際道具設定為 false,以便將其洗掉。
通過檔案 if country is US and international property is not passed then the phone number can only be input in the "national" format for US ((213) 373-4253). But if country is "US" and international property is true then the phone number can only be input in the "international" format for US (213 373 4253) without the "country calling code" part ( 1)
你的代碼應該是
<PhoneInput
placeholder={placeholder}
name={name}
value={value}
international = {false}
onChange={onValueChange}
onBlur={handleInputBlur}
onFocus={handleInputFocus}
defaultCountry={country}
countries={["NG", "MG", "SC", "KM", "BW", "MR"]}
/>
uj5u.com熱心網友回復:
紀錄片里有提到
默認國家:字串?— 如果指定了 defaultCountry,則可以以“國際”格式和“國家”格式輸入電話號碼。以“國家”格式輸入的電話號碼將被決議為屬于 defaultCountry 的電話號碼。必須是受支持的國家/地區代碼。示例:defaultCountry="US"。
源代碼:https : //www.npmjs.com/package/react-phone-number-input
<PhoneInput
placeholder={placeholder}
name={name}
value={value}
onChange={onValueChange}
onBlur={handleInputBlur}
onFocus={handleInputFocus}
defaultCountry={US}// ?? Instead of "country" specify the country
countries={["NG", "MG", "SC", "KM", "BW", "MR"]}
/>
請閱讀檔案
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/360700.html
上一篇:文本框驗證以確保只有整數值
