Skip to content

TextScroll 文字滚动

支持无缝滚动和打字机效果。在线演示

基础用法

vue
<template>
  <TextScroll :text="message" />
</template>

<script setup lang="ts">
const message = ref('系统将于今晚22:00进行维护升级,请提前保存工作内容。')
</script>

样式类型

vue
<TextScroll text="默认样式公告" type="default" />
<TextScroll text="成功样式公告" type="success" />
<TextScroll text="警告样式公告" type="warning" />
<TextScroll text="危险样式公告" type="danger" />
<TextScroll text="信息样式公告" type="info" />

速度和方向

vue
<!-- 滚动速度:数值越小越快 -->
<TextScroll :text="message" :speed="50" />

<!-- 向右滚动 -->
<TextScroll :text="message" direction="right" />

打字机效果

vue
<TextScroll :text="message" :typewriter="true" :typewriter-speed="80" />

可关闭公告

vue
<TextScroll :text="message" :show-close="true" @close="handleClose" />

Props

参数说明类型默认值
text滚动文本内容(必填)string
speed滚动速度,数值越小越快number70
direction滚动方向'left' | 'right''left'
type样式类型'default' | 'success' | 'warning' | 'danger' | 'info''default'
showClose是否显示关闭按钮booleanfalse
typewriter是否启用打字机效果booleanfalse
typewriterSpeed打字机速度,数值越小越快number100

Events

事件名说明回调参数
close关闭按钮点击时触发

XSS 风险

text 支持 HTML,使用时需注意 XSS 风险。

基于 MIT 许可发布 · 如需部署协助或二开定制,请查看 支持与合作