CoverView

覆盖在原生组件之上的文本视图。可覆盖的原生组件包括 map、video、canvas、camera、live-player、live-pusher 只支持嵌套 cover-view、cover-image,可在 cover-view 中使用 button。

参考文档

类型

  1. ComponentType<CoverViewProps>

示例代码

  • React
  • Vue
  1. // js
  2. class App extends Components {
  3. render () {
  4. return (
  5. <View className='container'>
  6. <Video id='myVideo' src='src'>
  7. <CoverView className='controls'>
  8. <CoverView className='play' onClick='play'>
  9. <CoverImage className='img' src='src' />
  10. </CoverView>
  11. </CoverView>
  12. </Video>
  13. </View>
  14. )
  15. }
  16. }
  17. // css
  18. .container {
  19. position: relative;
  20. }
  21. .controls {
  22. position: absolute;
  23. top: 50%;
  24. left: 50%;
  25. width: 300px;
  26. height: 225px;
  27. transform: translate(-50%, -50%);
  28. }
  1. <template>
  2. <view class="container">
  3. <video id='myvideo' src='https://ugccsy.qq.com/uwMROfz2r5zBIaQXGdGnC2dfDma3J1MItM3912IN4IRQvkRM/o31507f7lcd.mp4?sdtfrom=v1010&guid=aa18cf106b7fdb7e40f2d20b206f2b4f&vkey=63B0FCCC7FC3ADC342C166D86571AE02772258CD9B515B065DC68DF3919D8C288AE831D570ED5E8FE0FF3E81E170D04FF11F874BFDDACF7AAA2C0CFF2ACB39FB1A94DAD1AB859BDA53E4DD6DBCDC1217CEF789A9AC079924E2BBC599EED7A1FFDD60A727F2EB7E7B6472CE63DD4B683C9199DFC78A6A6C4D9891E05467C4B64E'>
  4. </video>
  5. <cover-view class='controls'>
  6. <cover-view class='play' @tap='play'>
  7. <cover-image class='img' src='https://img10.360buyimg.com/ling/s345x208_jfs/t1/133501/7/9865/382161/5f5ee31fEbdd6a418/0cdc0156ffff3c23.png' />
  8. </cover-view>
  9. </cover-view>
  10. </view>
  11. </template>
  12. <style>
  13. .container {
  14. position: relative;
  15. }
  16. .controls {
  17. position: absolute;
  18. top: 50%;
  19. left: 50%;
  20. width: 300px;
  21. height: 225px;
  22. transform: translate(-50%, -50%);
  23. }
  24. </style>

CoverViewProps

参数类型必填说明
scrollTopnumber设置顶部滚动偏移量,仅在设置了 overflow-y: scroll 成为滚动元素后生效

API 支持度

API微信小程序H5React Native
CoverViewProps.scrollTop✔️

API 支持度

API微信小程序百度小程序支付宝小程序H5React Native
CoverView✔️✔️✔️