Link 链接
LhLink 文字链接:语义色、下划线形态与禁用态,支持前后缀图标位。
基础用法
vue
<script setup lang="ts">
import { LhLink } from '@lh-ui/vue3'
</script>
<template>
<div class="demo-row">
<LhLink href="https://www.lhgb.top">默认链接</LhLink>
<LhLink href="https://www.lhgb.top" type="primary" target="_blank">主要链接(新窗口)</LhLink>
</div>
</template>vue
<script>
import { LhLink } from '@lh-ui/vue3'
export default {
components: { LhLink },
}
</script>
<template>
<div class="demo-row">
<LhLink href="https://www.lhgb.top">默认链接</LhLink>
<LhLink href="https://www.lhgb.top" type="primary" target="_blank">主要链接(新窗口)</LhLink>
</div>
</template>vue
<script setup lang="ts">
import { LhLink } from '@lh-ui/vue3'
</script>
<template>
<div class="demo-row">
<LhLink type="success">成功</LhLink>
<LhLink type="warning">警告</LhLink>
<LhLink type="danger" underline="always">常驻下划线</LhLink>
<LhLink underline="none">无下划线</LhLink>
</div>
</template>vue
<script>
import { LhLink } from '@lh-ui/vue3'
export default {
components: { LhLink },
}
</script>
<template>
<div class="demo-row">
<LhLink type="success">成功</LhLink>
<LhLink type="warning">警告</LhLink>
<LhLink type="danger" underline="always">常驻下划线</LhLink>
<LhLink underline="none">无下划线</LhLink>
</div>
</template>禁用态
禁用链接(不响应点击)
vue
<script setup lang="ts">
import { LhLink } from '@lh-ui/vue3'
</script>
<template>
<LhLink disabled>禁用链接(不响应点击)</LhLink>
</template>vue
<script>
import { LhLink } from '@lh-ui/vue3'
export default {
components: { LhLink },
}
</script>
<template>
<LhLink disabled>禁用链接(不响应点击)</LhLink>
</template>Link API
Props
| 属性名 | 说明 | 类型 | 默认值 |
|---|---|---|---|
| href | 链接地址(disabled 时不渲染 href) | string | — |
| target | 目标窗口(如 _blank) | string | — |
| type | 语义类型 | "default" | "primary" | "success" | "warning" | "danger" | "info" | — |
| underline | 下划线形态:always / hover / none | "always" | "hover" | "none" | 'hover' |
| disabled | 禁用:渲染为 span 且不跳转 | boolean | false |
| current | 当前页 / 当前位置标记(输出 aria-current) | true | "page" | "location" | — |
| sx | 快速布局属性,转内联样式作用于根元素 | LhSxProps | — |
Events
| 属性名 | 说明 | 类型 |
|---|---|---|
| click | 点击链接时触发 | (event: MouseEvent) |
Slots
| 属性名 | 说明 |
|---|---|
| default | 链接文本 |
| prefix | 前缀图标位 |
| suffix | 后缀图标位 |
无障碍
- 禁用时输出
aria-disabled="true"并保留role="link",读屏仍播报「链接」但明确不可用
类型定义
本组件对外导出的 TypeScript 类型结构如下(自动提取自 packages/components/link/src/types.ts 与 @lh-ui/share/core/* 源码,点击各条目展开查看完整定义;属性说明见上方 Props 表):
LhLinkProps
ts
export interface LhLinkProps {
/** 链接地址(disabled 时不渲染 href) */
href?: string
/** 目标窗口 */
target?: string
/** 链接语义类型 */
type?: LhLinkType
/** 下划线形态:always 常驻 / hover 悬停(默认)/ none 无 */
underline?: LhLinkUnderline
/** 禁用:灰化、不跳转、读屏播报不可用 */
disabled?: boolean
/** 当前页 / 当前位置标记(面包屑等场景,输出 aria-current) */
current?: 'page' | 'location' | true
/** sx 快速布局属性 */
sx?: LhSxProps
}
