【微信小程序 swiper swiper-item】

用swiper与swiper-item做轮播

【轮播效果】

代码:

bash 复制代码
	<swiper class="swiper-container">
	  <swiper-item>
	    <view class="item">A</view>
	  </swiper-item>
	  <swiper-item>
	    <view class="item">B</view>
	  </swiper-item>
	  <swiper-item>
	    <view class="item">C</view>
	  </swiper-item>
	</swiper>

样式

bash 复制代码
	.swiper-container {
	  height: 150px;
	}
	.item{
	  height: 100%;
	  text-align: center;
	  line-height: 150px;
	}
	swiper-item:nth-child(1) .item{
	  background-color: pink;
	}
	swiper-item:nth-child(2) .item{
	  background-color: red;
	}
	swiper-item:nth-child(3) .item{
	  background-color: gold;
	}

swiper当中常用的属性

  1. indicator-dots boolean false 是否显示面板指示点
  2. indicator-color color rgba(0, 0, 0,.3) 指示点颜色
  3. indicator-active-color color false 当前选中的指示点颜色
  4. autoplay boolean false 是否自动切换 interval number 5000 自动切换时间间隔
  5. circular boolean false 是否采用衔接滑动
  6. 属性名 indicator-dots
bash 复制代码
	<swiper class="swiper-container" 
	indicator-dots 
	indicator-color="#fff" 
	indicator-active-color="red" 
	autoplay interval="2000" 
	circular>
	  <swiper-item>
	    <view class="item">A</view>
	  </swiper-item>
	  <swiper-item>
	    <view class="item">B</view>
	  </swiper-item>
	  <swiper-item>
	    <view class="item">C</view>
	  </swiper-item>
	</swiper>

视频 发送弹幕

【发送弹幕效果】

先引入官方视频连接
http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023hy=SHfileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400

Xxx.wxml

bash 复制代码
	<!-- 弹幕小案例 -->
	<view>
	<!-- 视频 -->
	  <video
	  id="vi"
	  danmu-list="{{danmuList}}"
	  style="width: 100%;"
	  src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023hy=SHfileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400"/>
	</view>
	<!-- 发送弹幕 -->
	<view style="border: 1rpx solid;">
	  <!-- model 双向绑定 -->
	  <input model:value="{{danmuVal}}" type="text"/>
	</view>
	<button bind:tap="sendDanmu">发送弹幕</button>

Xxx.js

bash 复制代码
Page({
  data:{
    danmuList:[
      // 颜色 时间 文本
      {color:'red',time:1,text:'第一个弹幕'}
    ],
    danmuVal:""
  },
  onReady(){
    // 创建video上下文
    this.videoContext = wx.createVideoContext('vi')
  },
  // 点击发送弹幕
  sendDanmu(){
    // 调用video上下文的sendDanmu方法
    this.videoContext.sendDanmu({
      text:this.data.danmuVal,
      color:'pink'
    })
  }
})
相关推荐
说私域4 小时前
公域流量向私域流量转化策略研究——基于开源AI智能客服、AI智能名片与S2B2C商城小程序的融合应用
人工智能·小程序
半生过往4 小时前
微信小程序文件下载与预览功能实现详解
微信小程序·小程序·notepad++·压缩包下载解压
源码_V_saaskw4 小时前
JAVA图文短视频交友+自营商城系统源码支持小程序+Android+IOS+H5
java·微信小程序·小程序·uni-app·音视频·交友
weixin_lynhgworld7 小时前
淘宝扭蛋机小程序系统开发:重塑电商互动模式
大数据·小程序
996幸存者9 小时前
uni-app区域选择、支持静态、动态数据
微信小程序·uni-app
ᥬ 小月亮10 小时前
Uniapp编写微信小程序,绘制动态圆环进度条
微信小程序·小程序·uni-app
The_era_achievs_hero17 小时前
UniappDay03
vue.js·微信小程序·uni-app
说私域20 小时前
技术赋能与营销创新:开源链动2+1模式AI智能名片S2B2C商城小程序的流量转化路径研究
人工智能·小程序·开源
游戏开发爱好者81 天前
没有 Mac,如何上架 iOS App?多项目复用与流程标准化实战分享
android·ios·小程序·https·uni-app·iphone·webview
weixin_lynhgworld1 天前
代驾小程序系统开发:引领出行行业数字化转型
小程序