<!-- div--> <view v-if="setMsgTime(item.time,index > 0 ? list[index - 1].time : 0)"> <!-- 格式化時間 根據需求顯示時間格式,這裡time 格式為時間戳--> {{ formatMsgTime(item.time) }} </view> <!-- script --> setMsgTime(currTime, prevTime) { var timestampShowFlag = false; if (currTime <= 0) { timestampShowFlag = ''; } else if (!prevTime || prevTime <= 0) { timestampShowFlag = true; } else { const minDiffToShow = 10 * 60; // 10min 10*60s const diff = currTime - prevTime; // s if (diff >= minDiffToShow) { timestampShowFlag = true; } } return timestampShowFlag; }