Appearance
BizLinkInput 链接输入
链接类录入标准件(邮箱 / 网址双模式合一,同壳同值类型,type 切换校验与特性集):email 模式——格式校验(blur / input 两档)、@ 后常用域名后缀建议、企业域名白名单;url 模式——失焦协议自动补全(裸域名 → https://)、域名校验(可仅 https)、合法后缀新窗口预览。validate 状态外抛可直接挂 el-form rules。适用于注册登录、通讯录维护、官网 / 友情链接配置、webhook 回调设置等场景。
邮箱模式基础
当前值:support@example.com · 校验状态:empty
网址模式基础
邮箱后缀建议
企业域名白名单
邮箱即时校验
网址协议补全
当前值:(空)
仅 https 与关闭预览
自定义错误文案
el-form 集成
尺寸 / 禁用 / 占位
事件流
组合场景
未填写
Props
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| type | 'email' | 'url' | —(必填) | 链接类型:决定校验规则与可用特性集 |
| v-model | string | '' | 值(邮箱地址或含协议头的网址) |
| placeholder | string | 按类型 | 占位(email '请输入邮箱' / url 'https://example.com') |
| suggest | boolean | true | [email] @ 后常用域名后缀建议下拉 |
| allowed-domains | string[] | — | [email] 企业邮箱域名白名单(域外判 domain 错误) |
| validate-on | 'blur' | 'input' | 'blur' | [email] 错误提示时机(校验本身始终实时计算) |
| auto-prefix | boolean | true | [url] 失焦时裸域名自动补 https:// |
| https-only | boolean | false | [url] 仅允许 https(http 判 protocol 错误) |
| previewable | boolean | true | [url] 合法后缀显示新窗口预览链接 |
| maxlength | number | 按类型 | 最大长度(email 64 / url 2048) |
| clearable | boolean | true | 可清空 |
| disabled | boolean | false | 禁用 |
| size | 'small' | 'default' | 'large' | 'default' | 尺寸 |
| messages | Partial<Record<'format' | 'domain' | 'protocol', string>> | — | 自定义错误文案 |
Events
| 事件名 | 参数 | 说明 |
|---|---|---|
| validate | (status: BizLinkStatus) | 校验状态:empty / format / domain(email)/ protocol(url)/ valid |
| change | (value: string) | 值变化(含协议补全后的回写) |
| blur | (event: FocusEvent) | 失焦 |
Expose
| 属性/方法 | 说明 |
|---|---|
| validate | () => BizLinkStatus 同步校验并返回当前状态(el-form 校验器调用) |
口径说明
- 校验正则:email
^[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}$(域名比对忽略大小写);urlnew URL()解析成功且 hostname 含.,ftp://等非 http(s) 协议按 format 处理。 - 提示时机:状态始终实时计算,错误文案仅在
touched(失焦过或 emailvalidate-on=input)后展示;validate事件在输入与失焦时均外抛。 - url 补全顺序:失焦时先补协议再校验外抛;补全仅对「形如域名」的裸输入生效(
a.com/path→https://a.com/path)。 - 模式无关特性忽略:如 url 模式下传入
allowed-domains不参与校验(仅 email 模式生效),反之亦然。