tencent cloud

All product documents
Tencent Cloud Super App as a Service
Native Components
Last updated: 2025-04-22 18:11:25
Native Components
Last updated: 2025-04-22 18:11:25

Native Components

Our certain components are native, created by the client-side. These native components, implemented by the Mini Program client, boast superior performance and a richer array of features.
Native Components include:
camera: A camera component, utilized for invoking the camera to capture photographs or record videos;
Canvas: A canvas component, employed for the creation of graphics, animations, and the like;
input (Manifests as a native component only when in focus);
textarea: A multiline input box component, designed for the input of multiline text;
video: A video component, designed for video playback;
live-player: A real-time audio and video playback component used for playing live streams;
live-pusher:A real-time audio and video recording component used for pushing live streams;
map: A map component, utilized for the display of maps along with markers, routes, and other features on the map;
ad:Banner advertisement;
web-view:A container that hosts the H5 pages.

Usage restrictions for the native components

Given that native components exist outside of the WebView rendering process, the following limitations apply when using them:
The hierarchy of native components is of the highest order. Therefore, regardless of the 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.
Native components cannot be used within the <picker-view>.
Certain CSS styles cannot be applied to native components, for example:
CSS animations cannot be applied to native components.
Defining native components as position: fixed is not possible.
The display area of native components cannot be cropped by using overflow: hidden on parent nodes.
Event listeners for native components do not support the bind:eventname syntax, only bindeventname is supported. Native components also do not support event binding methods such as catch and capture.
Native components will obscure the debug panel popped up by vConsole.
Note:
On the tool, native components are simulated with web components. Hence, in many cases, they cannot accurately replicate the performance on a real device. It is recommended that developers debug on real devices whenever possible when using native components.

Non-same-layer rendering limitations on Android platform

Native components use same-layer rendering on iOS, while Android is non-same-layer rendering, so there are the following limitations specific to the Android platform:

​1. Absolute Layer Priority​

Android native components are always at the topmost layer of the view, even after the insertion of ordinary components can not be covered.

Solution:

Use the components cover-view and cover-image which are specially designed for overriding native components.
Example Code
<video>
<cover-view class="controls">Customize Play Control Button</cover-view>
</video>
Note:
Only supports nesting within the specified native component.
Limited style attributes (only simple styles such as opacity\\padding\\border-radius\\rotate\\scaleX\\scaleY\\width\\height\\left\\top\\background-color, etc. are supported).
Cannot contain other regular child components.

​2. Dynamic position adjustment is limited

When dynamically adjusting the position of native components, flickering and shadows may occur, especially when moving and scaling rapidly, the asynchronous rendering mechanism between the native rendering layer and the WebView view layer may lead to screen tearing.

Solution:

Respond to touch events via wxs, calculate coordinates in real time, and dynamically adjust the position of native components. Since wxs can directly handle events from the view layer, it reduces the communication overhead with the logic layer. For example, for frequently triggered touch events, wxs can be used to achieve better performance.
Example Code
WXML
WXS
WXSS
<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.wxs
let startY = 0; // Starting Y coordinate
let isStart = false; // Whether the sliding has started
let moveDistance = 0; // Distance moved
let currentOffset = 0; // Save cumulative offset

// Touch start event
function touchstart(event, ins) {
if (!isStart) {
isStart = true;
const touch = event.touches[0];
startY = touch.pageY;
}
}

// Touch move event
function touchmove(event, ins) {
const { pageY } = event.touches[0];
moveDistance = currentOffset + (pageY - startY);
// Update element position
ins.selectComponent('.videoBox').setStyle({
transform: `translateY(${moveDistance}px)`
});
}

// Touch end event
function 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;
}

3. Dynamic content update is limited

Delayed or flickering cover-view content updates (e.g. real-time text updates) over native components.

Solution:

Reduce high-frequency updates (e.g., control rendering frequency with an anti-jitter function), or switch to static content.
Example Code
WXML
JAVASCRIPT
<live-pusher>
<cover-view class="danmu">{{danmuText}}</cover-view>
</live-pusher>
// utils/debounce.js
function 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.js
const debounce = require('../../utils/debounce');

Page({
data: { danmuText: '' },
onLoad() {
// Create a debounced update function and bind the current Page's this
this.debouncedUpdateDanmu = debounce(this.updateDanmu.bind(this), 300);
},

updateDanmu(text) {
this.setData({ danmuText: text });
}

// Receive real-time WebSocket messages
onSocketMessage(msg) {
this.debouncedUpdateDanmu(msg.content); // High-frequency calls will be automatically merged
}
});

4. Bottom pop-up layer is limited

When you need to cover the full-screen native components (such as video, live-player) to realize the bottom pop-up layer, although it can be realized by cover-view, there will be the following limitations:
Interaction capability limitationcover-view only supports nested cover-view and cover-image, so the popup layer can't contain complex interactions such as form submission.
Performance bottleneck:If a large number of cover-views or cover-images need to be inserted into the popup layer, it is easy to cause rendering lag.

Solution:

Dynamically adjust the height of the native component container so that there is no overlap between the popup layer and the native component in the layout, so that the popup layer can be realized by using a common component (e.g. view).
Example Code
WXML
JAVASCRIPT
WXSS
<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;
}

Was this page helpful?
You can also Contact Sales or Submit a Ticket for help.
Yes
No

Feedback

Contact Us

Contact our sales team or business advisors to help your business.

Technical Support

Open a ticket if you're looking for further assistance. Our Ticket is 7x24 available.

7x24 Phone Support
Hong Kong, China
+852 800 906 020 (Toll Free)
United States
+1 844 606 0804 (Toll Free)
United Kingdom
+44 808 196 4551 (Toll Free)
Canada
+1 888 605 7930 (Toll Free)
Australia
+61 1300 986 386 (Toll Free)
EdgeOne hotline
+852 300 80699
More local hotlines coming soon