Marquee 垂直滚动

使用指南

在 page.json 中引入组件

"usingComponents": {
  "w-marquee": "wuss-weapp/w-marquee/index",
  "w-marquee-item": "wuss-weapp/w-marquee-item/index",
}

视频演示

代码演示

<w-pane title="Marquee" desc="垂直滚动视图" />

<w-pane desc="Default" />

<w-button bind:onClick="handleClick1" type="info">+1</w-button>

<w-button bind:onClick="handleClick2" type="info">jump to 8</w-button>

<w-button bind:onClick="handleClick3" type="info">jump to 1</w-button>

<w-button bind:onClick="handleClick4" type="info">Next Item</w-button>

<view
 class=""
 hover-class="none"
 hover-stop-propagation="false"
>
	<w-marquee
	 bind:onChange="handleChange"
	 default-index="{{ 6 }}"
	 current-index="{{ currentIndex }}"
	>
		<w-marquee-item
		 bind:onClick="handleChange"
		 data-url="{{ item.url }}"
		 wx:for="{{ arr }}"
		 wx:key="item"
		 wuss-class="w-marquee-item"
		>
			<view style="background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAJIAAAAgCAYAAAD5eSHwAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAAyJpVFh0WE1MOmNvbS5hZG9iZS54bXAAAAAAADw/eHBhY2tldCBiZWdpbj0i77u/IiBpZD0iVzVNME1wQ2VoaUh6cmVTek5UY3prYzlkIj8+IDx4OnhtcG1ldGEgeG1sbnM6eD0iYWRvYmU6bnM6bWV0YS8iIHg6eG1wdGs9IkFkb2JlIFhNUCBDb3JlIDUuMy1jMDExIDY2LjE0NTY2MSwgMjAxMi8wMi8wNi0xNDo1NjoyNyAgICAgICAgIj4gPHJkZjpSREYgeG1sbnM6cmRmPSJodHRwOi8vd3d3LnczLm9yZy8xOTk5LzAyLzIyLXJkZi1zeW50YXgtbnMjIj4gPHJkZjpEZXNjcmlwdGlvbiByZGY6YWJvdXQ9IiIgeG1sbnM6eG1wPSJodHRwOi8vbnMuYWRvYmUuY29tL3hhcC8xLjAvIiB4bWxuczp4bXBNTT0iaHR0cDovL25zLmFkb2JlLmNvb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Y8c1Mja5BbGiVsm+jc5zLgqglatR3sGsmXmPz0yPrII5C6YUMARO516xRcjnTTTQ93nbNm0XCdTkCbNpC6enVIyodj4UKq9mnTQghJLUkhddN37Ag4+RTIW7fSNkh4IpjSi4tjsoisbBLnsvIRZv69KtzSV8I9jHUHQzCJX0umMBDi23VghOUSoQ4C4TF2jcSLVs7SSG6scnQ2RvCF1JxC/NXLjyAd7M5h9aMavlgyM+kZnP/6dXAWFFCfRDNM37yZRlD28eMhecAAGqKLablJWVmhL1JRAd7z58Nuq+hk+86epdtb7cGDAf8o5d13qc8kpwHHAkhZbDVvYZN8TaUegmY742Fw8g4xa6NnMhCUmJaCiTCYgNwbJKa6ivN3shjPVFRHlFbKLCASjn8wfqlGxxhusGd8w8BUIPhj9Q9hiIVxk23NvXIl9UnqrE/CdOf06eBevhySR4xQPXYJIq8GvMeOgXPRImrVNFmDsjJwzp0rbadctIe+2b+DBkEy6gsvxIbuSPzS1oURZhNIiCLqzjh61NCP5hK/tAX4OvEJVH1bSADJmEwHKZ03IZKcFyLdBJB0Cp7ldQHplzTXb+PvgL4xJhHiWWeZ0cb/CTAABWTbJuxwP2AAAAAASUVORK5CYII=);background-size: 100% 100%;width: 73px;height: 16px;margin-right: 10px;" />
			<view
			 class=""
			 hover-class="none"
			 hover-stop-propagation="false"
			 style="font-size: 14px;"
			>
				{{ item.title }}
				{{ index }}
			</view>
		</w-marquee-item>
	</w-marquee>
</view>

<view
 class=""
 hover-class="none"
 hover-stop-propagation="false"
>
	<w-marquee
	 default-index="{{ 0 }}"
	 item-height="666.75"
	 current-index="{{ currentIndex }}"
	>
		<w-marquee-item
		 bind:onClick="handleChange"
		 data-url="{{ item.url }}"
		 wx:for="{{ arr }}"
		 wx:key="item"
		>
			<image style="width: 100%;height: 100%;display:block;margin: 0;padding: 0;" src="{{ item.imgSrc }}" />
		</w-marquee-item>
	</w-marquee>
</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 过渡时间,默认为3s number 3000
defaultIndex 初始化后默认的索引 number 0
itemHeight 每个子节点(w-marquee-item)的高度 number 44
currentIndex 设置当前的激活索引 number 0

Event 事件

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

Slot 插槽

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

Class 自定义类名

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