Represents a text view that covers system components.
It can be used on the map, video, canvas, and camera components.
Important notes:
The cover-view component is designed for compatibility with earlier versions of mini programs. For new projects, use the view component.
Since version 1.0.22, the nested content within the map, video, canvas, and camera components is displayed by default. In earlier versions, the nested content within the tags is not displayed by default.
Since: 1.0.22
Attributes
| Name | Type | Default Value | Mandatory | Description |
|---|---|---|---|---|
| hover-class | string | none | No | Style class for the pressed state. The value "none" indicates no pressed effect. |
| hover-start-time | number | 50 | No | Delay before the pressed state appears upon pressing, in milliseconds. |
| hover-stay-time | number | 400 | No | Retention time of the pressed state after the finger is lifted, in milliseconds. |
| hover-stop-propagation | boolean | false | No | Whether to disable the pressed effect of the ancestor node. |
Example:
HXML file:
<map
id="myMap"
class="my-map-container"
latitude="{{ latitude }}"
longitude="{{ longitude }}"
scale="16"
show-location>
<cover-view class="cover-container">
<cover-view
class="cover-title"
hover-class="title-hover"
hover-start-time="100">
cover-view
</cover-view>
<cover-view
class="cover-stay"
hover-class="stay-hover"
hover-stay-time="1000"
bindtap="onCoverTap">
The effect is retained for 1,000 ms after tapping.
</cover-view>
<cover-view class="test-box" hover-class="parent-hover">
<cover-view class="test-child" hover-class="child-hover">
Normal bubbling: Both the parent and child nodes are highlighted.
</cover-view>
</cover-view>
<cover-view class="test-box" hover-class="parent-hover">
<cover-view
class="test-child"
hover-class="child-hover"
hover-stop-propagation="{{true}}">
Bubbling prevention: The parent node is not highlighted.
</cover-view>
</cover-view>
</cover-view>
</map> JavaScript file:
Page({
data: {
latitude: 39.908823,
longitude: 116.397470
},
onCoverTap() {
has.showToast({
title: 'Button tapped successfully',
icon: 'success'
});
}
}); CSS file:
.my-map-container {
width: 100%;
height: 100vh;
}
.cover-container {
position: absolute;
top: 30rpx;
left: 30rpx;
right: 30rpx;
padding: 30rpx;
background: rgba(255, 255, 255, 0.95);
border-radius: 12rpx;
}
.cover-title {
font-size: 34rpx;
font-weight: bold;
text-align: center;
padding: 15rpx;
margin-bottom: 25rpx;
}
.title-hover {
background: #f5f5f5;
color: #0066ff;
}
.cover-stay {
background: #e8f3ff;
padding: 20rpx;
text-align: center;
border-radius: 8rpx;
margin-bottom: 25rpx;
}
.stay-hover {
background: #409eff;
color: #fff;
}
.test-box {
padding: 25rpx;
border: 2rpx solid #eee;
margin-bottom: 20rpx;
transition: all 0.2s;
text-align: center;
}
.parent-hover {
background: #fff5cc;
border-color: #ff9500;
}
.test-child {
padding: 20rpx;
background: #f7f7f7;
border-radius: 8rpx;
}
.child-hover {
background: #409eff;
color: #fff;
}