[Taro] Build Taro project to WeChat Mini Program
Taro Getting Started - WeChat Mini Program
Taro is an open cross-terminal and cross-framework solution that supports the use of React/Vue/Nerv and other frameworks to develop applications such as WeChat/JD/Baidu/Alipay/ByteDance/QQ applet/H5.
WeChat Mini Program is a new open capability, and developers can quickly develop a Mini Program. Mini programs can be easily acquired and disseminated in WeChat, and have an excellent user experience.
Prerequisites
Taro depends on the Node.js environment, so you must download and install the Node.js environment on your machine from the following:
-
Node.js - https://nodejs.org/en/
Node.js® is a JavaScript runtime built on Chrome’s V8 JavaScript engine.
For more information about installing and using Node.js, see the Node.js - https://nodejs.org/en/
-
nvm is a version manager for node.js, designed to be installed per-user, and invoked per-shell. nvm works on any POSIX-compliant shell (sh, dash, ksh, zsh, bash), in particular on these platforms: unix, macOS, and windows WSL.
-
asdf-nodejs is a Node.js plugin for asdf version manager.
-
The Missing Package Manager for macOS (or Linux) - https://formulae.brew.sh/formula/node
Homebrew installs the stuff you need that Apple (or your Linux system) didn’t.
WeChat Mini Program need a development and debugging tools, so you need download and install WeChat Developer Tools from the following:
-
WeChat Developer Tools - https://developers.weixin.qq.com/miniprogram/en/dev/devtools/download.html
WeChat Developer Tools is a web debugging tools to help developers develop and debug Weixin Mini Programs more simply and efficiently based on the original Official Account.
Installation
1 | npm i @tarojs/cli |
(Optinal) Upgrade Taro
1 | taro update self |
Taro Init
Run taro init [project name]
to create a new project.
1 | taro init col-taro-example |
Check Taro information.
1 | taro |
WeChat Mini Program
Use the following commands to compile Taro project to WeChat Mini Program.
1 | yarn |
Mini Program Developer Tools
Download and open the WeChat Developer Tools - https://developers.weixin.qq.com/miniprogram/en/dev/devtools/download.html, and then select col-taro-example/dist
directory as the project root directory to preview.
Need to pay attention to the project settings of the developer tools:
-
You need to set to turn off the ES6 to ES5 function, and it may report an error if it is turned on
-
You need to set to turn off the automatic completion of the style when uploading the code, and an error may be reported
-
You need to set the code compression upload to be disabled, and an error may be reported when it is enabled
References
[1] 安装及使用 | Taro 文档 - https://taro-docs.jd.com/taro/docs/GETTING-STARTED
[2] Taro | 多端统一开发解决方案 - https://taro.jd.com/
[4] WeChat Developer Tools - https://developers.weixin.qq.com/miniprogram/en/dev/devtools/download.html
[5] 微信小程序 - https://mp.weixin.qq.com/cgi-bin/wx?token=&lang=zh_CN