【微信小程序 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'
    })
  }
})
相关推荐
matlab_xiaowang1 小时前
【2025】Notepad++安装教程保姆级一键安装教程(附安装包)
其他·notepad++
低代码布道师5 小时前
少儿舞蹈小程序(7)打造您的“活”名片:动态展示机构实力
低代码·小程序
程序员陆通8 小时前
用 Cursor AI 快速开发你的第一个编程小程序
人工智能·小程序
鹧鸪云光伏与储能软件开发8 小时前
投资储能项目能赚多少钱?小程序帮你测算
运维·数据库·小程序·光伏·光伏设计软件·光伏设计
微三云-轩9 小时前
小程序:12亿用户的入口,企业数字化的先锋军
大数据·小程序·开源软件
低代码布道师9 小时前
少儿舞蹈小程序(8)校区信息后台搭建
低代码·小程序
2501_916008899 小时前
iOS 抓包工具有哪些?全面盘点主流工具与功能对比分析
android·ios·小程序·https·uni-app·iphone·webview
2501_915921439 小时前
iOS混淆工具实战 视频流媒体类 App 的版权与播放安全保护
android·ios·小程序·https·uni-app·iphone·webview
SY_FC12 小时前
uniapp阿里云验证码使用
阿里云·uni-app·notepad++
—Qeyser13 小时前
好看的背景颜色 uniapp+小程序
小程序·uni-app·uniapp·微信小游戏