CoverImage

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

参考文档

类型

  1. ComponentType<CoverImageProps>

示例代码

  • 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. )
  14. }
  15. }
  16. // css
  17. .container {
  18. position: relative;
  19. }
  20. .controls {
  21. position: absolute;
  22. top: 50%;
  23. left: 50%;
  24. width: 300px;
  25. height: 225px;
  26. transform: translate(-50%, -50%);
  27. }
  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>

CoverImageProps

参数类型必填说明
srcstring图标路径,支持临时路径、网络地址、云文件ID。暂不支持base64格式。
onLoadBaseEventOrigFunction<any>图片加载成功时触发
onErrorBaseEventOrigFunction<any>图片加载失败时触发

API 支持度

API微信小程序H5React Native
CoverImageProps.src✔️
CoverImageProps.onLoad✔️
CoverImageProps.onError✔️

API 支持度

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