z-index set for other components on the page, they cannot overlay the native components. Subsequently inserted native components can overlay the previously inserted ones.<picker-view>.position: fixed is not possible.overflow: hidden on parent nodes.bind:eventname syntax, only bindeventname is supported. Native components also do not support event binding methods such as catch and capture.<video><cover-view class="controls">Customize Play Control Button</cover-view></video>
opacity\\padding\\border-radius\\rotate\\scaleX\\scaleY\\width\\height\\left\\top\\background-color, etc. are supported).<wxs src="./index.wxs" module="touch" /><view class="container"><view class="videoBox"bind:touchstart="{{touch.touchstart}}"bind:touchmove="{{touch.touchmove}}"bind:touchend="{{touch.touchend}}"><video class="video-item" src="Video address 1" controls /><video class="video-item" src="Video address 2" controls /><video class="video-item" src="Video address 3" controls /></view></view>
// index.wxslet startY = 0; // Starting Y coordinatelet isStart = false; // Whether the sliding has startedlet moveDistance = 0; // Distance movedlet currentOffset = 0; // Save cumulative offset// Touch start eventfunction touchstart(event, ins) {if (!isStart) {isStart = true;const touch = event.touches[0];startY = touch.pageY;}}// Touch move eventfunction touchmove(event, ins) {const { pageY } = event.touches[0];moveDistance = currentOffset + (pageY - startY);// Update element positionins.selectComponent('.videoBox').setStyle({transform: `translateY(${moveDistance}px)`});}// Touch end eventfunction touchend(event, ins) {isStart = false;currentOffset = moveDistance;}module.exports = {touchstart,touchmove,touchend};
.container {width: 100vw;height: 100%;position: relative;overflow: hidden;top: 0;position: absolute;background: #000;}.videoBox {width: 100vw;height: 100%;position: absolute;}.video-item {width: 100vw;height: 100%;display: block;}
<live-pusher><cover-view class="danmu">{{danmuText}}</cover-view></live-pusher>
// utils/debounce.jsfunction debounce(fn, delay = 300, immediate = false) {let timer = null;return function (...args) {if (timer) clearTimeout(timer);if (immediate && !timer) {fn.apply(this, args); // Execute immediately once}timer = setTimeout(() => {if (!immediate) {fn.apply(this, args);}timer = null;}, delay);};}module.exports = debounce;// pages/live.jsconst debounce = require('../../utils/debounce');Page({data: { danmuText: '' },onLoad() {// Create a debounced update function and bind the current Page's thisthis.debouncedUpdateDanmu = debounce(this.updateDanmu.bind(this), 300);},updateDanmu(text) {this.setData({ danmuText: text });}// Receive real-time WebSocket messagesonSocketMessage(msg) {this.debouncedUpdateDanmu(msg.content); // High-frequency calls will be automatically merged}});
video, live-player) to realize the bottom pop-up layer, although it can be realized by cover-view, there will be the following limitations:cover-view only supports nested cover-view and cover-image, so the popup layer can't contain complex interactions such as form submission.cover-views or cover-images need to be inserted into the popup layer, it is easy to cause rendering lag.view).<view class="container"><live-pusher class="liver-pusher" url="{{pusherUrl}}" autopush="{{true}}" mode="RTC"><cover-view class="action-button" catchtap="handleOpen">Open the pop-up layer</cover-view><cover-view class="action-button close" catchtap="handleClose">Close the pop-up layer</cover-view></live-pusher><view class="comments-modal" wx:if="{{open}}"><input placeholder="This is an input"/></view></view>
Page({data: {open: false,},handleOpen: function () {this.setData({open: true})},handleClose: function () {this.setData({open: false})},})
.container {width: 100vw;height: 100vh;display: flex;flex-direction: column;background-color: #000;}.liver-pusher {width: 100%;flex: 1;}.action-button {position: absolute;height: 50px;line-height: 50px;text-align: center;background-color: white;}.close {left: 100px;}.comments-modal {width: 100%;background-color: #fff;height: 40vh;}
Feedback