Introduction
Framework
The goal of the mini-program development framework is to enable developers to create services with a native app experience in an efficient and straightforward manner.
The entire mini-program framework is divided into two parts: the logic layer (App Service) and the view layer (View). Mini-programs provide their own view layer description language called DLT and CSS, along with a JavaScript-based logic layer framework. They also provide data transmission and event systems between the view layer and the logic layer, allowing developers to focus on data and logic.
Responsive Data Binding
The core of the framework is a responsive data binding system that allows data and views to stay in sync very easily. When data is modified, you only need to modify it in the logic layer, and the view layer will be updated accordingly.
Consider this simple example:
<!-- This is our View -->
<view> Hello {{name}}! </view>
<button bind:tap="changeName"> Click me! </button>
// This is our App Service.
// This is our data.
var helloData = {
name: 'Transsion'
}
// Register a Page.
Page({
data: helloData,
changeName: function(e) {
// Send data change to view
this.setData({
name: 'MINA'
})
}
})
- Developers bind the data in the logic layer, specifically the
name
in the logic layer's data, to thename
in the view layer. So, when the page opens, it displays "Hello Transsion!". - When the button is clicked, the view layer sends the
changeName
event to the logic layer. The logic layer finds and executes the corresponding event handling function. - After the callback function is triggered, the logic layer performs the
setData
operation, changing thename
from "Transsion" to "MINA". Because this data is bound to the view layer, the view automatically updates to display "Hello MINA!".
Page Management
The framework manages the entire mini-program's page routing, enabling seamless transitions between pages and providing complete page lifecycles. Developers only need to register page data, methods, and lifecycle functions with the framework, while all other complex operations are handled by the framework.
Basic Components
The framework provides a set of basic components that come with a native style and special logic. Developers can create powerful mini-programs by combining these basic components.
Rich API
The framework offers a rich set of native mini-program APIs, making it easy to access capabilities provided by the mini-program, such as user information retrieval, local storage, payment functions, and more.