【微信小程序 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'
    })
  }
})
相关推荐
Mr.app3 小时前
uniapp(微信小程序)>关于父子组件的样式传递问题(自定义组件样式穿透)
微信小程序·uni-app
老李不敲代码3 小时前
榕壹云搭子系统技术解析:基于Spring Boot+MySQL+UniApp的同城社交平台开发实践
spring boot·mysql·微信小程序·uni-app·软件需求
全职计算机毕业设计1 天前
基于微信小程序的城市特色旅游推荐应用的设计与实现
微信小程序·小程序
gaojianqiao12341 天前
uniapp引入七鱼客服微信小程序SDK
微信小程序·uni-app
说私域1 天前
线下消费经济“举步维艰”,开源AI智能名片链动2+1+S2B2C小程序线上“狂飙突进”!
人工智能·小程序·开源·零售
天上掉下来个程小白1 天前
添加购物车-02.代码开发
java·服务器·前端·后端·spring·微信小程序·苍穹外卖
JAVA叶知秋2 天前
uniapp自定义底部导航栏h5有效果小程序无效的解决方案
小程序·uni-app
沙尘暴炒饭2 天前
用uniapp在微信小程序实现画板(电子签名)功能,使用canvas实现功能
微信小程序·小程序·uni-app
PyAIGCMaster2 天前
Taro 编译不平不同平台小程序
小程序
fakaifa3 天前
【开源版】likeshop上门家政系统PHP版全开源+uniapp前端
小程序·uni-app·php·家政小程序源码·家政服务小程序·源码下载·上门家政