1# marquee 2<!--Kit: ArkUI--> 3<!--Subsystem: ArkUI--> 4<!--Owner: @hddgzw--> 5<!--Designer: @pssea--> 6<!--Tester: @jiaoaozihao--> 7<!--Adviser: @HelloCrease--> 8 9跑马灯组件,用于展示一段单行滚动的文字。 10 11> **说明:** 12> 13> 该组件从API version 4 开始支持。后续版本如有新增内容,则采用上角标单独标记该内容的起始版本。 14 15 16## 子组件 17 18不支持。 19 20 21## 属性 22 23| 名称 | 类型 | 默认值 | 必填 | 描述 | 24| -------- | -------- | -------- | -------- | -------- | 25| scrollamount | number | 6 | 否 | 跑马灯每次滚动时移动的最大长度。 | 26| id | string | - | 否 | 组件的唯一标识。 | 27| style | string | - | 否 | 组件的样式声明。 | 28| class | string | - | 否 | 组件的样式类,用于引用样式表。 | 29| ref | string | - | 否 | 用来指定指向子元素的引用信息,该引用将注册到父组件的$refs 属性对象上。 | 30 31 32## 事件 33 34| 名称 | 参数 | 描述 | 35| -------- | -------- | -------- | 36| click | - | 点击动作触发该事件。 | 37| longpress | - | 长按动作触发该事件。 | 38| swipe<sup>5+</sup> | [SwipeEvent](js-lite-common-events.md) | 组件上快速滑动后触发。 | 39 40 41## 样式 42 43| 名称 | 类型 | 默认值 | 必填 | 描述 | 44| -------- | -------- | -------- | -------- | -------- | 45| color | <color> | \#ffffff| 否 | 设置跑马灯中文字的文本颜色。 | 46| font-size | <length> | 30 | 否 | 设置跑马灯中文字的文本尺寸。 | 47| font-family | string | SourceHanSansSC-Regular | 否 | 字体。目前仅支持SourceHanSansSC-Regular 字体。 | 48| width | <length> \| <percentage><sup>5+</sup> | - | 否 | 设置组件自身的宽度。<br/>未设置时组件宽度默认为0。 | 49| height | <length> \| <percentage><sup>5+</sup> | - | 否 | 设置组件自身的高度。<br/>未设置时组件高度默认为0。 | 50| padding | <length> | 0 | 否 | 使用简写属性设置所有的内边距属性。<br/> 该属性可以有1到4个值:<br/>- 指定一个值时,该值指定四个边的内边距。<br/>- 指定两个值时,第一个值指定上下两边的内边距,第二个指定左右两边的内边距。<br/>- 指定三个值时,第一个指定上边的内边距,第二个指定左右两边的内边距,第三个指定下边的内边距。<br/>- 指定四个值时分别为上、右、下、左边的内边距(顺时针顺序)。 | 51| padding-[left\|top\|right\|bottom] | <length> | 0 | 否 | 设置左、上、右、下内边距属性。 | 52| margin | <length> \| <percentage><sup>5+</sup> | 0 | 否 | 使用简写属性设置所有的外边距属性,该属性可以有1到4个值。<br/>- 只有一个值时,这个值会被指定给全部的四个边。<br/>- 两个值时,第一个值被匹配给上和下,第二个值被匹配给左和右。<br/>- 三个值时,第一个值被匹配给上; 第二个值被匹配给左和右;第三个值被匹配给下。<br/>- 四个值时,会依次按上、右、下、左的顺序匹配 (即顺时针顺序)。 | 53| margin-[left\|top\|right\|bottom] | <length> \| <percentage><sup>5+</sup> | 0 | 否 | 设置左、上、右、下外边距属性。 | 54| border-width | <length> | 0 | 否 | 使用简写属性设置元素的所有边框宽度。 | 55| border-color | <color> | black | 否 | 使用简写属性设置元素的所有边框颜色。 | 56| border-radius | <length> | - | 否 | border-radius属性是设置元素的外边框圆角半径。 | 57| background-color | <color> | - | 否 | 设置背景颜色。 | 58| opacity<sup>5+</sup> | number | 1 | 否 | 元素的透明度,取值范围为0到1,1表示为不透明,0表示为完全透明。 | 59| display | string | flex | 否 | 确定一个元素所产生的框的类型,可选值为:<br/>- flex:弹性布局。<br/>- none:不渲染此元素。 | 60| [left\|top] | <length> \| <percentage><sup>6+</sup> | - | 否 | left\|top确定元素的偏移位置。<br/>- left属性规定元素的左边缘。该属性定义了定位元素左外边距边界与其包含块左边界之间的偏移。<br/>- top属性规定元素的顶部边缘。该属性定义了一个定位元素的上外边距边界与其包含块上边界之间的偏移。 | 61 62## 示例 63 64```html 65<!-- xxx.hml --> 66<div class="container"> 67 <marquee class="customMarquee" scrollamount="{{scrollAmount}}">{{marqueeCustomData}}</marquee> 68 <text class="text" onclick="addSpeed">speed+</text> 69 <text class="text" onclick="downSpeed">speed-</text> 70 <text class="text" onclick="changeData">changeData</text> 71</div> 72``` 73 74```css 75/* xxx.css */ 76.container { 77 flex-direction: column; 78 width: 100%; 79 height: 100%; 80 flex-direction: column; 81 align-items: center; 82} 83.customMarquee { 84 width: 50%; 85 height: 80px; 86 padding: 10px; 87 margin: 20px; 88 border-width: 4px; 89 border-color: #ffffff; 90 border-radius: 20px; 91 font-size: 38px; 92} 93.text { 94 font-size: 30px; 95 text-align: center; 96 width: 30%; 97 height: 10%; 98 margin-top: 5%; 99 background-color: #f2f2f2; 100 border-radius: 40px; 101 color: #0d81f2; 102} 103``` 104 105```javascript 106// xxx.js 107export default { 108 data: { 109 scrollAmount: 30, 110 marqueeCustomData: 'Custom marquee Custom marquee Custom marquee' 111 }, 112 addSpeed() { 113 this.scrollAmount++; 114 }, 115 downSpeed() { 116 this.scrollAmount--; 117 }, 118 changeData() { 119 this.marqueeCustomData = 'Change Data Change Data Change Data'; 120 } 121} 122``` 123 124