# Link 链接

文字链接:语义色、下划线形态与禁用态,支持前后缀图标位。禁用时渲染为 span 且不跳转,读屏仍播报「链接」但明确不可用。

链接
<template>
  <div class="demo-col" style="gap: 18px">
    <div class="demo-row" style="gap: 16px; flex-wrap: wrap">
      <LhLink href="https://www.lhgb.top" target="_blank">默认链接</LhLink>
      <LhLink type="primary" href="https://www.lhgb.top" target="_blank">主要链接</LhLink>
      <LhLink type="success">成功</LhLink>
      <LhLink type="warning">警告</LhLink>
      <LhLink type="danger" underline="always">常驻下划线</LhLink>
      <LhLink type="info" underline="none">无下划线</LhLink>
    </div>
    <div class="demo-row" style="gap: 16px; flex-wrap: wrap">
      <LhLink disabled>禁用链接(不响应点击)</LhLink>
      <LhLink href="https://www.lhgb.top" @click.prevent="onClicked">
        <template #prefix>→</template>
        前后缀图标位
        <template #suffix>←</template>
      </LhLink>
    </div>
    <p class="demo-note">
      {{ clicked ? '已拦截默认跳转,click 事件已触发' : '点击「前后缀图标位」触发 click(已阻止默认跳转)' }}
    </p>
  </div>
</template>

<script>
export default {
  data: () => ({
    clicked: false,
  }),
  methods: {
    onClicked() {
      this.clicked = true
    },
  },
}
</script>

# Props

属性 说明 类型 默认值
href 链接地址(disabled 时不渲染 href) string —
target 目标窗口(如 _blank) string —
type 语义类型 'default' \| 'primary' \| 'success' \| 'warning' \| 'danger' \| 'info' 'default'
underline 下划线形态:always / hover / none 'always' \| 'hover' \| 'none' 'hover'
disabled 禁用:渲染为 span 且不跳转 boolean false
current 当前页 / 当前位置标记(输出 aria-current) true \| 'page' \| 'location' —
sx sx 快速布局 — —

# Events

事件 说明 回调参数
click 点击链接时触发(禁用时不触发) (event: MouseEvent)

# Slots

名称 说明
default 链接文本
prefix 前缀图标位
suffix 后缀图标位

# 无障碍

  • 禁用时输出 aria-disabled="true" 并保留 role="link"
  • current 有值时输出 aria-current(面包屑当前页等场景)
最后更新: 2026/12/4 00:49:57

Copyright © 2024-2026 风默文学 | 宁ICP备2024006574号 | 公安备案徽标苏公网安备32040002010537