2. Cloud development in practice
2. Configure the current cloud development environment
3. Understand the directory structure
4. Cloud function operation process
5. Upload the cloud function to the cloud service
6. Basic operations (add, delete, modify, check)
foreword
WeChat applet cloud development:
1. No need to build a server, just use the various capabilities provided by the platform to quickly develop business.
2. There is no need to manage certificates, signatures, and secret keys, and directly call the WeChat API. Reuse WeChat private protocols and links to ensure business security.
3. Support environment sharing. One back-end environment can develop multiple small programs, official accounts, web pages, etc., and reuse business codes and data conveniently.
4. Support pay-as-you-go mode, the back-end resources are automatically expanded according to the business traffic, use it first and then pay, without paying idle costs.
提示:以下是本篇文章正文内容,下面案例可供参考
1. Quick start
Preparations: If you are using the WeChat Mini Program for the first time, you must click to view
Including the account registration application, the creation process of WeChat applet cloud development, etc. (skip here);
2. Cloud development in practice
1. Enable cloud development
Open cloud environment
2. Configure the current cloud development environment
3. Understand the directory structure
Understand the file directory
4. Cloud function operation process
Cloud function main entrance
Cloud functions operate on databases
Local code calls cloud functions
5. Upload the cloud function to the cloud service
1. Deploy cloud functions
2. Upload and update the cloud function ( if you modify the cloud function, you must remember to update )
6. Basic operations (add, delete, modify, check)
const cloud = require('wx-server-sdk') //引入微信及sdk
cloud.init({
env: cloud.DYNAMIC_CURRENT_ENV //配置默认开发环境
})
const db = cloud.database() //链接数据库
name | the code |
Add | |
delete | |
Revise | |
Inquire | |
Summarize
WeChat applet cloud development: it is convenient, fast, time-saving, labor-saving and money-saving for small projects; it is recommended not to use the cloud development model for large-scale projects;
Be sure to read the WeChat applet cloud development document cloud development document address https://developers.weixin.qq.com/miniprogram/dev/wxcloud/basis/getting-started.html
demo download address https://gitcode.net/weixin_41620505/wechat_cloud