组件/KeyframeStrokeText 关键帧描边
通用组件

KeyframeStrokeText 关键帧描边

把任意文本渲染为先描边、后填充的关键帧动画。

该页面由 AI 迁移生成,请谨慎使用

内容已迁移完成,但仍建议结合源码和人工评审结果使用。

KeyframeStrokeText 关键帧描边

把任意文本渲染为先描边、后填充的关键帧动画。

基础用法

KeyframeStrokeText

示例即将加载...
<template>
  <div style="display: flex; flex-direction: column; gap: 18px;">
    <TxKeyframeStrokeText text="TuffEx" :font-size="56" />

    <TxKeyframeStrokeText
      text="Stroke + Fill"
      stroke-color="#0ea5e9"
      fill-color="#0f172a"
      :duration-ms="2400"
      :stroke-width="1.8"
      :font-size="42"
      :font-weight="600"
    />
  </div>
</template>

中文文案示例

Chinese text

示例即将加载...
<template>
  <TxKeyframeStrokeText
    text="关键帧描边动画"
    stroke-color="#16a34a"
    fill-color="#14532d"
    :duration-ms="2600"
    :stroke-width="1.6"
    :font-size="40"
    :font-weight="700"
  />
</template>

API

Props

属性名类型默认值说明
textstring''要渲染的文本内容
strokeColorstring#4C4CFF描边颜色
fillColorstring#111827填充颜色
durationMsnumber1800动画时长(ms)
strokeWidthnumber2描边宽度
fontSizestring | number64字号
fontWeightstring | number700字重
fontFamilystringinherit字体族

交互契约

  • 组件渲染一个 role="img" 的 SVG;text 非空时作为 aria-label
  • text 为空时使用 non-breaking-space 保持 SVG 测量和占位,不输出 aria-label
  • fontSize 为 number 时会转换为 px;durationMsstrokeWidth、颜色和字体参数通过 CSS 变量驱动动画。
  • 挂载后会同步测量文本尺寸,并在文本、字体或描边宽度变化时重新测量。