Marquee 垂直滚动

使用指南

在 page.json 中引入组件

  1. "usingComponents": {
  2. "w-marquee": "wuss-weapp/w-marquee/index",
  3. "w-marquee-item": "wuss-weapp/w-marquee-item/index",
  4. }

视频演示

代码演示

  1. <w-pane title="Marquee" desc="垂直滚动视图" />
  2. <w-pane desc="Default" />
  3. <w-button bind:onClick="handleClick1" type="info">+1</w-button>
  4. <w-button bind:onClick="handleClick2" type="info">jump to 8</w-button>
  5. <w-button bind:onClick="handleClick3" type="info">jump to 1</w-button>
  6. <w-button bind:onClick="handleClick4" type="info">Next Item</w-button>
  7. <view
  8. class=""
  9. hover-class="none"
  10. hover-stop-propagation="false"
  11. >
  12. <w-marquee
  13. bind:onChange="handleChange"
  14. default-index="{{ 6 }}"
  15. current-index="{{ currentIndex }}"
  16. >
  17. <w-marquee-item
  18. bind:onClick="handleChange"
  19. data-url="{{ item.url }}"
  20. wx:for="{{ arr }}"
  21. wx:key="item"
  22. wuss-class="w-marquee-item"
  23. >
  24. <view style="background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJIAAAAgCAYAAAD5eSHwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmU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/akz42GYOqIrDyQnuB4l93Mmoi+C7r+s0BKjZXlkgq/AwIf9KEAULWJNDH+ShY8c1Mja5BbGiVsm+jc5zLgqglatR3sGsmXmPz0yPrII5C6YUMARO516xRcjnTTTQ93nbNm0XCdTkCbNpC6enVIyodj4UKq9mnTQghJLUkhddN37Ag4+RTIW7fSNkh4IpjSi4tjsoisbBLnsvIRZv69KtzSV8I9jHUHQzCJX0umMBDi23VghOUSoQ4C4TF2jcSLVs7SSG6scnQ2RvCF1JxC/NXLjyAd7M5h9aMavlgyM+kZnP/6dXAWFFCfRDNM37yZRlD28eMhecAAGqKLablJWVmhL1JRAd7z58Nuq+hk+86epdtb7cGDAf8o5d13qc8kpwHHAkhZbDVvYZN8TaUegmY742Fw8g4xa6NnMhCUmJaCiTCYgNwbJKa6ivN3shjPVFRHlFbKLCASjn8wfqlGxxhusGd8w8BUIPhj9Q9hiIVxk23NvXIl9UnqrE/CdOf06eBevhySR4xQPXYJIq8GvMeOgXPRImrVNFmDsjJwzp0rbadctIe+2b+DBkEy6gsvxIbuSPzS1oURZhNIiCLqzjh61NCP5hK/tAX4OvEJVH1bSADJmEwHKZ03IZKcFyLdBJB0Cp7ldQHplzTXb+PvgL4xJhHiWWeZ0cb/CTAABWTbJuxwP2AAAAAASUVORK5CYII=);background-size: 100% 100%;width: 73px;height: 16px;margin-right: 10px;" />
  25. <view
  26. class=""
  27. hover-class="none"
  28. hover-stop-propagation="false"
  29. style="font-size: 14px;"
  30. >
  31. {{ item.title }}
  32. {{ index }}
  33. </view>
  34. </w-marquee-item>
  35. </w-marquee>
  36. </view>
  37. <view
  38. class=""
  39. hover-class="none"
  40. hover-stop-propagation="false"
  41. >
  42. <w-marquee
  43. default-index="{{ 0 }}"
  44. item-height="666.75"
  45. current-index="{{ currentIndex }}"
  46. >
  47. <w-marquee-item
  48. bind:onClick="handleChange"
  49. data-url="{{ item.url }}"
  50. wx:for="{{ arr }}"
  51. wx:key="item"
  52. >
  53. <image style="width: 100%;height: 100%;display:block;margin: 0;padding: 0;" src="{{ item.imgSrc }}" />
  54. </w-marquee-item>
  55. </w-marquee>
  56. </view>
arr: [
  {
    title: '廊坊发生刑事案件',
    url: 'xxxx',
    imgSrc: 'http://img5.imgtn.bdimg.com/it/u=2918240254,2454690875&fm=26&gp=0.jpg',
  },
  {
    title: '小伙四万网购奔驰',
    url: 'xxxx',
    imgSrc: 'http://img3.imgtn.bdimg.com/it/u=3013567159,2250112086&fm=26&gp=0.jpg',
  },
  {
    title: '家人去世请假被拒',
    url: 'xxxx',
    imgSrc: 'http://img5.imgtn.bdimg.com/it/u=180988904,275450817&fm=26&gp=0.jpg',
  },
  {
    title: '于正秒删',
    url: 'xxxx',
    imgSrc: 'http://img2.imgtn.bdimg.com/it/u=1094944933,4065700883&fm=26&gp=0.jpg',
  },
  {
    title: '岳华去世',
    url: 'xxxx',
    imgSrc: 'http://img1.imgtn.bdimg.com/it/u=822102141,3878875172&fm=26&gp=0.jpg',
  },
  {
    title: '美将退出中导条约',
    url: 'xxxx',
    imgSrc: 'http://img4.imgtn.bdimg.com/it/u=1828593470,806721422&fm=26&gp=0.jpg',
  },
  {
    title: '范丞丞悼念粉丝',
    url: 'xxxx',
    imgSrc: 'http://img4.imgtn.bdimg.com/it/u=3939936779,946895769&fm=26&gp=0.jpg',
  },
  {
    title: '梅西骨折',
    url: 'xxxx',
    imgSrc: 'http://img4.imgtn.bdimg.com/it/u=3830398842,3489851318&fm=26&gp=0.jpg',
  },
  {
    title: '女子踩到男子',
    url: 'xxxx',
    imgSrc: 'http://img3.imgtn.bdimg.com/it/u=3348027003,368668260&fm=26&gp=0.jpg',
  },
  {
    title: '福原爱宣布退役',
    url: 'xxxx',
    imgSrc: 'http://img1.imgtn.bdimg.com/it/u=440375388,3364532017&fm=26&gp=0.jpg',
  },
  {
    title: '郭炳湘病逝',
    url: 'xxxx',
    imgSrc: 'http://img4.imgtn.bdimg.com/it/u=3133605357,944042545&fm=26&gp=0.jpg',
  },
],
currentIndex: null,
},
.w-marquee-item {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  padding: 10px;
}

page {
  padding: 0;
}

API

Attribute 属性

属性说明类型默认值
interval过渡时间,默认为3snumber3000
defaultIndex初始化后默认的索引number0
itemHeight每个子节点(w-marquee-item)的高度number44
currentIndex设置当前的激活索引number0

Event 事件

事件名说明参数
onChange改变值后的回调e.detail.value

Slot 插槽

名称说明
marquee-itemmarquee的滚动子节点

Class 自定义类名

类名说明
wuss-class根节点样式类