minapp
Redefining the development of WeChat mini programs
Change log
minapp 2.0.0 has been released. The new version mainly uses webpack 4. Please check the upgrade from v1.x to v2.x.
introduce
minapp is a set of tools built for developing WeChat applets to improve the development experience:
- Provides a command line tool
@minapp/cli
, which can be used to quickly create a project and use webpack to build the generated project; - Provide a development framework
@minapp/core
. This framework is fully compatible with native applet code. It supports development using classes, supports automatic code completion, and also provides automatic completion of all WeChat APIs. - Provides a framework
@minapp/mobx
that integrates mobx. This framework mainly injects mobx into @minapp/core
, allowing you to easily use mobx to manage global data. - Provide a vscode plug-in
minapp-vscode
. This plug-in is mainly a wxml
template language for small programs. It can automatically complete all components, component attributes, component attribute values, etc.
Note: After using minapp, you still need to use the "WeChat Developer Tools" officially provided by WeChat for testing.
use
- Use npm to install command line tools:
npm install -g @minapp/cli
- Initialize the project:
minapp init <你要创建项目的文件夹>
(supports the creation of js and ts projects at the same time) - Install two vscode plug-ins: minapp and dot-template (optional, but recommended)
Features
- Fully compatible with native mini programs, all native mini program codes can be directly migrated to the minapp environment
- Integrate webpack and webpack-dev-server to ensure compilation
- You can choose to use mobx to facilitate global data management
- All languages can be automatically completed in the minapp environment, and the development experience is super great (see
功能概览
below) - Support two-way data binding
- setData performance optimization
Function overview (under vscode editor)
All wx interfaces have intelligent reminders, including interface parameters and return values.
Non-minapp users can also install @minapp/wx
to get this feature, see here
Provides a promise version of the wx interface wxp, which is the same as wx, except that it will promise all functions in wx that require three parameters of success/fail/complete
- wxp also supports the use of success callbacks
- wxp adds a finally method to Promise; for example, you can use
wxp.getUserInfo().finally(() => { /* do something */ })
Integrating mobx makes it very convenient to modify global data and automatically update the current page status.
- To inject Store, you only need to add the Store object in the appify function.
- Store objects are injected into Page and Component by default. You can use
this.store
to obtain them.
The wxml template language supports syntax highlighting, component smart prompts, and component attribute smart prompts (the vscode plug-in minapp needs to be installed)
For more details about the functions of this plug-in, click here to view
json file supports automatic prompts
When creating a new page folder, related files are automatically generated (vscode plug-in dot-template needs to be installed)
- Automatically create relevant files with the same name for you, including js/json/wxml/scss, and you can modify these template files at any time in the .dtpl folder.
- Automatically inject the newly created page path into the app.json folder
The mini program Page supports automatic function prompts.
In the same way, when creating a new component folder, related files will also be created; at the same time, the life cycle function in the component will also automatically prompt
About this warehouse description
This is not one project, it is a combination of several projects, using the lerna development tool. Other projects are in the packages directory. Here is a brief overview of several of the main projects.
- minapp-generator: This module is responsible for parsing WeChat official documents and generating structured data for use by other modules.
- minapp-wx: TypeScript definitions of all native APIs of WeChat, and also provides a promise version of the wx interface
- minapp-core: development framework, needs to depend on minapp-wx
- minapp-mobx: A development framework that integrates mobx and needs to rely on minapp-core
- minapp-cli: A command line tool provided to users and can quickly create a new project
- minapp-vscode: vscode plug-in, providing syntax highlighting, automatic completion of tags and attributes for wxml
TODO