用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当中常用的属性
- indicator-dots boolean false 是否显示面板指示点
- indicator-color color rgba(0, 0, 0,.3) 指示点颜色
- indicator-active-color color false 当前选中的指示点颜色
- autoplay boolean false 是否自动切换 interval number 5000 自动切换时间间隔
- circular boolean false 是否采用衔接滑动
- 属性名 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'
})
}
})