- cover-view
- cover-image
- Bug & Tips
- Bug & Tips
cover-view
覆盖在原生组件之上的文本视图,可覆盖的原生组件包括map、video、canvas、camera、live-player、live-pusher,只支持嵌套cover-view、cover-image,可在cover-view中使用button。
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| scroll-top | Number / String | 设置顶部滚动偏移量,仅在设置了 overflow-y: scroll 成为滚动元素后生效 | |
| aria-role | String | 无障碍访问,(角色)标识元素的作用 | |
| aria-label | String | 无障碍访问,(属性)元素的额外描述 |
cover-image
覆盖在原生组件之上的图片视图,可覆盖的原生组件同cover-view,支持嵌套在cover-view里。
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| src | String | 图标路径,支持临时路径、网络地址、云文件ID。暂不支持base64格式。 | |
| bindload | EventHandle | 图片加载成功时触发 | |
| binderror | EventHandle | 图片加载失败时触发 | |
| aria-role | String | 无障碍访问,(角色)标识元素的作用 | |
| aria-label | String | 无障碍访问,(属性)元素的额外描述 |
Bug & Tips
tip:<cover-view>和<cover-image>的aria-role仅可设置为button,读屏模式下才可以点击,并朗读出“按钮”;为空时可以聚焦,但不可点击tip: 事件模型遵循冒泡模型,但不会冒泡到原生组件。tip: 文本建议都套上cover-view标签,避免排版错误。tip: 只支持基本的定位、布局、文本样式。不支持设置单边的border、background-image、shadow、overflow: visible等。tip: 建议子节点不要溢出父节点tip: 默认设置的样式有:white-space: nowrap;line-height: 1.2;display: block;bug: 自定义组件嵌套cover-view时,自定义组件的 slot 及其父节点暂不支持通过 qq:if 控制显隐,否则会导致cover-view不显示
<videoid="myVideo"src="https://qzonestyle.gtimg.cn/qzone/qzact/act/external/qq-video/qq-video.mp4"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, 0.5);color: white;line-height: 50px;}.img {width: 40px;height: 40px;margin: 5px auto;}
Page({onReady() {this.videoCtx = qq.createVideoContext('myVideo')},play() {this.videoCtx.play()},pause() {this.videoCtx.pause()}})
