小程序组件

视图容器-cover-view

时间:2018/12/20 14:12:43  作者:互联网  来源:网络转载  查看:7499  评论:0
内容摘要:cover-view基础库 1.4.0 开始支持,低版本需做兼容处理。覆盖在原生组件之上的文本视图,可覆盖的原生组件包括map、video、canvas、camera、live-player、live-pusher,只支持嵌套cover-view、cover-image,可在co...

cover-view

基础库 1.4.0 开始支持,低版本需做兼容处理。

覆盖在原生组件之上的文本视图,可覆盖的原生组件包括mapvideocanvascameralive-playerlive-pusher,只支持嵌套cover-viewcover-image,可在cover-view中使用button

属性名 类型 默认值 说明 最低版本
scroll-top Number / String   设置顶部滚动偏移量,仅在设置了 overflow-y: scroll 成为滚动元素后生效(单位px或rpx,默认为px) 2.1.0

cover-image

基础库 1.4.0 开始支持,低版本需做兼容处理。

覆盖在原生组件之上的图片视图,可覆盖的原生组件同cover-view,支持嵌套在cover-view里。

属性名 类型 默认值 说明 最低版本
src String   图标路径,支持临时路径、网络地址(1.6.0起支持)、云文件ID(2.2.3起支持)。暂不支持base64格式。  
bindload EventHandle   图片加载成功时触发 2.1.0
binderror EventHandle   图片加载失败时触发 2.1.0
Bug & Tips
  1. tip: 基础库 2.2.4 起支持 touch 相关事件,也可使用 hover-class 设置点击态
  2. tip: 基础库 2.1.0 起支持设置 scale rotate 的 css 样式,包括 transition 动画
  3. tip: 基础库 1.9.90 起 cover-view 支持 overflow: scroll,但不支持动态更新 overflow
  4. tip: 基础库 1.9.90 起最外层 cover-view 支持 position: fixed
  5. tip: 基础库 1.9.0 起支持插在 view 等标签下。在此之前只可嵌套在原生组件mapvideocanvascamera内,避免嵌套在其他组件内。
  6. tip: 基础库 1.6.0 起支持css transition动画,transition-property只支持transform (translateX, translateY)opacity
  7. tip: 基础库 1.6.0 起支持css opacity。
  8. tip: 事件模型遵循冒泡模型,但不会冒泡到原生组件。
  9. tip: 文本建议都套上cover-view标签,避免排版错误。
  10. tip: 只支持基本的定位、布局、文本样式。不支持设置单边的borderbackground-imageshadowoverflow: visible等。
  11. tip: 建议子节点不要溢出父节点
  12. tip: 默认设置的样式有:white-space: nowrap; line-height: 1.2; display: block;
  13. bug: 自定义组件嵌套 cover-view 时,自定义组件的 slot 及其父节点暂不支持通过 wx:if 控制显隐,否则会导致 cover-view 不显示

示例:

<video id="myVideo" src="http://wxsnsdy.tc.qq.com/105/20210/snsdyvideodownload?filekey=30280201010421301f0201690402534804102ca905ce620b1241b726bc41dcff44e00204012882540400&bizid=1023&hy=SH&fileparam=302c020101042530230204136ffd93020457e3c4ff02024ef202031e8d7f02030f42400204045a320a0201000400" controls="{{false}}" event-model="bubble">
  <cover-view class="controls">
    <cover-view class="play" bindtap="play">
      <cover-image class="img" src="/path/to/icon_play" />
    </cover-view>
    <cover-view class="pause" bindtap="pause">
      <cover-image class="img" src="/path/to/icon_pause" />
    </cover-view>
    <cover-view class="time">00:00</cover-view>
  </cover-view>
</video>
.controls {
  position: relative;
  top: 50%;
  height: 50px;
  margin-top: -25px;
  display: flex;
}
.play,.pause,.time {
  flex: 1;
  height: 100%;
}
.time {
  text-align: center;
  background-color: rgba(0, 0, 0, .5);
  color: white;
  line-height: 50px;
}
.img {
  width: 40px;
  height: 40px;
  margin: 5px auto;
}
Page({
  onReady() {
    this.videoCtx = wx.createVideoContext('myVideo')
  },
  play() {
    this.videoCtx.play()
  },
  pause() {
    this.videoCtx.pause()
  }
})


上一篇:没有了
下一篇:视图容器-movable-area
相关文章
    相关评论
    评论者:      验证码:  点击获取验证码
    咨询QQ/微信:45157718 点击这里给我发消息 | 电话:13516821613 | 浙江杭州余杭区东港路118号雷恩科技创新园 | 网站支持:杭州摇亿网络科技 | 浙ICP备06056032号-6 |