tencent cloud

Tencent Cloud Super App as a Service

Release Notes and Announcements
Announcement: Tencent Cloud Mini Program Platform Renamed to Tencent Cloud Super App as a Service on January 2, 2025
Console Updates
Android SDK Updates
iOS SDK Updates
Flutter SDK Updates
IDE Updates
Base Library Updates
Product Introduction
Overview
Strengths
Use Cases
Purchase Guide
Billing Overview
Pay-As-You-Go Billing
Renewal Guide
Service Suspension Instructions
Getting Started
Plan Management
Overview
Console Account Management
Storage Configuration
Acceleration Configuration
Branding Configurations
Platform Features
Console Login
Users and Permission System
Mini Program Management
Mini Game Management
Superapp Management
Commercialization
Platform Management
User Management
Team Management
Operations Management
Security Center
Code Integration Guide
Getting Demo and SDK
Android
iOS
Flutter
Superapp Server
GUID Generation Rules
Mini Program Development Guide
Mini Program Introduction and Development Environment
Mini Program Code Composition
Guide
Framework
Components
API
Server Backend
JS SDK
Base Library
IDE Operation Instructions
Mini Game Development Guide
Guide
API
Server Backend
Practice Tutorial
Mini Program Login Practical Tutorial
Mini Program Subscription Message Practical Tutorial
Payment Practical Tutorial
Ad Integration Practical Tutorial
Mini Game Subscription Message Practical Tutorial
API Documentation
History
Introduction
API Category
Making API Requests
Operation Management APIs
User Management APIs
Team Management APIs
Sensitive API-Related APIs
Role Management APIs
Platform Management APIs
Other Console APIs
Mini Program or Mini Game APIs
Management-Sensitive APIs
Global Domain Management APIs
Superapp APIs
Data Types
Agreements
Service Level Agreement
Data Processing and Security Agreement
SDK Privacy Policy Module
SDK Data Processing and Security Agreement Module

Base Library Introduction

PDF
聚焦模式
字号
最后更新时间: 2025-01-16 19:31:09

Introduction

The base library acts as a middleware responsible for loading mini programs. It pre-packages many capabilities of the app and the phone (such as Bluetooth, NFC, etc.), allowing developers to use standard components and APIs to develop mini programs.
You can think of the base library as similar to common web development libraries like React or Lodash. However, it is more specialized because the capabilities of mini programs require support from the SDK. Therefore:
The base library, like the host app, has its own version number.
New capabilities added in each version of the base library need to run in specific versions.
Some capabilities of higher versions of the base library are not compatible with lower version SDKs.

Typically, the base library provides two main parts for mini program developers: components and APIs.
WXML files in mini programs, when compiled, can render real DOM nodes in the environment provided by the base library.
APIs like Page and Component used in JS files of mini programs are also exposed globally by the base library.
The wx.xxx APIs used in mini programs actually call native capabilities (like Bluetooth, WiFi, etc.), and the base library acts as a "bridge" between the mini program and the native container.

In short, the base library mainly handles data binding, provides a component system, event system, communication system, and other framework logic. From the dual-process model perspective, it includes rendering issues of the Virtual DOM in the rendering layer and built-in components and APIs in the logic layer. Additionally, the base library provides supplementary capabilities for mini programs, such as custom components and performance compatibility.
const {SDKVersion} = wx.getSystemInfoSync(); // fetch jsLib version

Base library mechanism

When developing web pages, we often reference third-party JavaScript libraries. Before using the APIs provided by these libraries, we need to include them in our business code.

Similarly, when opening a mini program in an app, we need to load the base library before starting the mini program, and then load the business code. Since the rendering layer and logic layer of mini programs are managed by two threads, when we talk about the base library, it usually includes the WebView base library (rendering layer) and the AppService base library (logic layer).

Before opening any mini program based on our platform, the same base library needs to be injected. Therefore, we do not need to package the base library in the mini program's code package. Instead, you need to integrate our mini program SDK in the app and introduce the mini program base library through the SDK. Introducing the base library through the SDK has two benefits:
It can reduce the size of the mini program code package.
It allows adding capabilities or fixing bugs in the base library without modifying the mini program's code.

Mini program startup
When you open a mini program, you'll see a loading page that includes the mini program's icon and name. On this page, the base library and code package are downloaded first. Once the downloads are complete, the base library and code package are loaded separately.


帮助和支持

本页内容是否解决了您的问题?

填写满意度调查问卷,共创更好文档体验。

文档反馈