开发预览 更新于 2026-05-10

PhoneInput 电话号码输入

国家码下拉 + 号码输入。内置 12 个常见国家,可通过 countries 覆盖。

基础用法

国家码段独立背景,下拉支持模糊搜索。本组件不做 E.164 校验,由消费方接 libphonenumber 等库。

CN · 138 0013 8000
<CfPhoneInput v-model="phone" v-model:country="country" />
<CfPhoneInput value={phone} onChange={setPhone} country={country} onCountryChange={setCountry} />

尺寸 / 错误 / 禁用

error 切红边,disabled 整体灰化。

<CfPhoneInput v-model="v" :error="true" />
<CfPhoneInput v-model="v" disabled />
<CfPhoneInput value={v} onChange={setV} error />
<CfPhoneInput value={v} onChange={setV} disabled />

API

属性类型默认值说明
modelValue / valuestring''国内号码段
countrystring'CN'ISO 3166-1 alpha-2
countriesCountryCode[]defaultCountries(12 项)自定义国家列表
size / placeholder / disabled / error

CountryCode = { code: string; dial: string; label: string }

反馈与讨论

PhoneInput 电话号码输入 的讨论

0
0 / 600
一键发送
正在加载评论...