跳转到内容

marquee

跑马灯组件,用于展示一段滚动文字,默认为单行显示。

不支持子组件。

支持通用属性

名称类型默认值必填描述
scrollamount<number>1每秒滚动的距离,单位:px。
loop<number>3滚动的次数,默认值为 3。
direction<string>left滚动方向,可选值:leftright
text-offset<number>0设置内容首尾相接时的间距,需为大于 0 的整数,单位:px。
double-ended-shadow<bool>true是否显示两端阴影效果。
double-ended-shadow-color<color>rgb(0,0,0)两端阴影的颜色

支持通用样式

名称类型默认值必填描述
color<color>rgba(0, 0, 0, 0.54)文字颜色。
font-size<length>30px文字大小。
font-family<string>-字体名称,当前仅支持 HYQiHei-65S
text-alignleftcenterrightleft

支持通用事件

名称参数描述
bounce-当 marquee 滚动至末尾时触发
finish-当 marquee 按照 loop 属性设置的次数滚动完成时触发。仅当 loop 设置为大于 0 的数值时有效。
start-当 marquee 开始滚动时触发
名称参数描述
start-开始滚动 marquee
stop-停止滚动 marquee
<template>
<div class="container">
<marquee>这段文字展示跑马灯效果默认连续滚动ABCDEFGHIJKLMN</marquee>
<marquee id="marquee" loop="1" onbounce="bounce" onfinish="finish" onstart="start">
这段文字展示跑马灯效果滚动一次ABCDEFGHIJKLMN
</marquee>
<input type="button" class="btn" @click="startHandler" value="start" />
<input type="button" class="btn" @click="stopHandler" value="stop" />
</div>
</template>
<script>
import prompt from '@system.prompt'
export default {
startHandler() {
this.$element('marquee').start()
},
stopHandler() {
this.$element('marquee').stop()
},
bounce() {
prompt.showToast({
message: 'bounce',
})
},
finish() {
prompt.showToast({
message: 'finish',
})
},
start() {
prompt.showToast({
message: 'start',
})
},
}
</script>
<style>
.container {
width: 100%;
height: 100%;
flex-direction: column;
align-items: center;
justify-content: center;
}
marquee {
width: 500px;
height: 80px;
color: #9acd32;
font-size: 50px;
margin: 20px 0;
}
.btn {
width: 300px;
height: 80px;
text-align: center;
border-radius: 5px;
color: #ffffff;
font-size: 30px;
background-color: #0faeff;
margin: 20px;
}
</style>