Framework
The goal of the Mini Program development framework is to enable developers to develop services with a native APP experience on WeChat in a simplest and most efficient way possible.
The framework provides its own view layer description languages WXML and WXSS, as well as a JavaScript-based logical layer framework, and provides a data transfer and event system between the view layer and the logical layer, allowing developers to easily focus on data and logic.
Responsive data binding
The core of the framework is a responsive data binding system.
The entire system is divided into a view layer (View) and a logic layer (App Service).
The framework keeps data and views in sync in a simple way. When the data needs to be changed, you only need to modify it in the logical layer, and the view layer will update accordingly.
Look at this simple example:
<!-- This is our View -->
<view> Hello {{name}}! </view>
<button bindtap="changeName"> Click me! </button>
// This is our App Service.
// This is our data.
var helloData = {
name: 'WeChat'
}
// Register a Page.
Page({
data: helloData,
changeName: function(e) {
// sent data change to view
this.setData({
name: 'MINA'
})
}
})
- The developer binds
name
in the logical layer data to thename
of the view layer through the framework, soHello WeChat!
is displayed when the page is opened. - When the button is clicked, the view layer sends
changeName
event to the logical layer, and the logical layer finds the corresponding event handler. - The logic layer performs
setData
operation, changing the name fromWeChat
toMINA
because the data and view layer are already bound, so the view layer is automatically changed toHello MINA!
.
Page management
The framework manages the entire page routing of Mini Program, which enables seamless switching between pages and gives the page a complete lifecycle. The developer only needs to do is register the data, methods, and lifecycle functions of the page into the framework, while all other complicated operations are handled by the framework.
Basic components
The framework provides a set of basic components that come with WeChat styles and special logic. The developers can create powerful WeChat Mini Programs by combining such base components.
Rich APIs
The framework provides a rich set of WeChat native APIs, which can easily invoke the capabilities provided by WeChat, such as user information access, local storage, and payment functions.