微信小程序cover-view 与cover-image

使用cover-view 与 cover-image 是实现覆盖在原生组件之上的文本视图。

效果图

微信小程序cover-view 与cover-image_第1张图片

 

效果图代码

 wxml


    

      
      
      
      
      

     

wxss

.cov_view{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  height: 140rpx;
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  margin-bottom: 50rpx;
}
.cov_image{
  width: 100rpx;
  height: 100rpx;
}

.center_image{
  width: 300rpx;
  height: 100rpx;
}

 

属性如下

cover-image

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

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

属性 类型 默认值 必填 说明 最低版本
src string   图标路径,支持临时路径、网络地址(1.6.0起支持)、云文件ID(2.2.3起支持)。暂不支持base64格式。 1.4.0
bindload eventhandle   图片加载成功时触发 2.1.0
binderror eventhandle   图片加载失败时触发 2.1.0

 

cover-view

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

覆盖在原生组件之上的文本视图。

可覆盖的原生组件包括 map、video、canvas、camera、live-player、live-pusher

只支持嵌套 cover-view、cover-image,可在 cover-view 中使用 button。组件属性的长度单位默认为px,2.4.0起支持传入单位(rpx/px)。

属性 类型 默认值 必填 说明 最低版本
scroll-top number/string   设置顶部滚动偏移量,仅在设置了 overflow-y: scroll 成为滚动元素后生效 2.1.0

Bug & Tip

  1. tiparia-role仅可设置为button,读屏模式下才可以点击,并朗读出“按钮”;为空时可以聚焦,但不可点击
  2. tip: 基础库 2.2.4 起支持 touch 相关事件,也可使用 hover-class 设置点击态
  3. tip: 基础库 2.1.0 起支持设置 scale rotate 的 css 样式,包括 transition 动画
  4. tip: 基础库 1.9.90 起 cover-view 支持 overflow: scroll,但不支持动态更新 overflow
  5. tip: 基础库 1.9.90 起最外层 cover-view 支持 position: fixed
  6. tip: 基础库 1.9.0 起支持插在 view 等标签下。在此之前只可嵌套在原生组件mapvideocanvascamera内,避免嵌套在其他组件内。
  7. tip: 基础库 1.6.0 起支持css transition动画,transition-property只支持transform (translateX, translateY)opacity
  8. tip: 基础库 1.6.0 起支持css opacity。
  9. tip: 事件模型遵循冒泡模型,但不会冒泡到原生组件。
  10. tip: 文本建议都套上cover-view标签,避免排版错误。
  11. tip: 只支持基本的定位、布局、文本样式。不支持设置单边的borderbackground-imageshadowoverflow: visible等。
  12. tip: 建议子节点不要溢出父节点
  13. tip: 默认设置的样式有:white-space: nowrap; line-height: 1.2; display: block;
  14. bug: 自定义组件嵌套 cover-view 时,自定义组件的 slot 及其父节点暂不支持通过 wx:if 控制显隐,否则会导致 cover-view 不显示

 

 一般cover-view 都是与cover-image 一起使用,当然单独使用也行,一起使用布局方便一些,

并不是只能使用cover-view与cover-image才能实现刚才的效果,使用view 与 image也行 

代码如下


    

      
      
      
       
       
     
.cov_view{
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  height: 140rpx;
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  margin-bottom: 50rpx;
}
.cov_image{
  width: 100rpx;
  height: 100rpx;
}

.center_image{
  width: 300rpx;
  height: 100rpx;
}

 

 

你可能感兴趣的:(微信小程序,微信小程序)