现象:callout窗口中的内容点击显示时偶尔出现内容显示不全问题,如下图所示
正常情况应如下图所示:
<map id="map" class="map" :markers="markers" :longitude="longitude" :latitude="latitude" @markertap="handleMarkerTap" @tap="handleMapTap" @regionchange="handleMapMove">
<cover-view slot="callout">
<block v-for="(item, index) in markers" :key="item.userId">
<cover-view class="callout-container" :marker-id="item.id" :class="{active: item.id == showCalloutMarkerId}">
<cover-view class="callout-container-main">
<cover-view class="callout-header" :class="item.calloutData.status ? 'on-line' : 'off-line'">
<cover-view class="title">{{ item.calloutData.userName }}</cover-view>
<cover-view class="status">
<cover-view class="dot"></cover-view>
<cover-view>{{ item.calloutData.status ? '在线' : '离线' }}</cover-view>
</cover-view>
</cover-view>
<cover-view class="split-line"></cover-view>
<cover-view class="callout-content">
<cover-view class="callout-content-item">
<cover-view class="title">当前位置:</cover-view>
<cover-view class="value">
{{ item.calloutData.address }}
</cover-view>
</cover-view>
<cover-view class="callout-content-item">
<cover-view class="title">最后更新:</cover-view>
<cover-view class="value">
{{ item.calloutData.time }}
</cover-view>
</cover-view>
</cover-view>
</cover-view>
<cover-view class="callout-arrow"></cover-view>
</cover-view>
</block>
</cover-view>
</map>
js:
handleMapTap(e) {
console.log('handleMarkerTap', e);
},
handleMarkerTap(e) {
console.log('点击了标记点:', e.detail.markerId);
if(e.markerId == this.showCalloutMarkerId){
return;
}
this.showCalloutMarkerId = e.markerId;
},
handleMapMove() {
}
css:
.callout-container {
width: 480rpx;
position: relative;
z-index: 9999;
display: none;
&.active {
display: block;
}
.callout-container-main {
background: #ffffff;
padding: 24rpx;
border-radius: 16rpx;
}
.callout-header {
display: flex;
justify-content: space-between;
margin-bottom: 18rpx;
&.on-line {
--status-color: #67C23A;
}
&.off-line {
--status-color: #F56C6C;
}
.title {
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.status {
display: flex;
align-items: center;
color: var(--status-color);
font-weight: bold;
font-size: 28rpx;
.dot {
display: inline-block;
width: 16rpx;
height: 16rpx;
background: var(--status-color);
border-radius: 100%;
margin-right: 10rpx;
}
}
}
.callout-content {
padding-top: 18rpx;
.callout-content-item {
display: flex;
overflow: hidden;
& + .callout-content-item {
margin-top: 24rpx;
}
.title {
flex-shrink: 0;
font-weight: bold;
font-size: 28rpx;
color: #333333;
}
.value {
flex: 1;
font-size: 28rpx;
color: #28A066;
overflow: hidden;
word-break: break-word;
overflow-wrap: break-word;
white-space: normal;
}
}
}
.split-line {
width: 100%;
height: 2rpx;
background: #DBDBDB;
}
.callout-arrow {
margin: auto;
width: 32rpx;
height: 32rpx;
background: #ffffff;
transform: translate(-50%, -50%) rotate(45deg);
}
}

朋友,解决了吗