微信小程序开发之云开发

157 阅读1分钟

创建云开发小程序项目

![](https://upload-images.jianshu.io/upload_images/4345694-2ca5795c31bcde17.png?imageMogr2/auto-orient/strip|imageView2/2/w/1000/format/webp)
file

开通云开发

![](https://upload-images.jianshu.io/upload_images/4345694-9011cd140f97a2c7.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file
![](https://upload-images.jianshu.io/upload_images/4345694-1b6424c0c279d13c.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

开通后界面

![](https://upload-images.jianshu.io/upload_images/4345694-42965b6d8814da39.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

选择开发环境

![](https://upload-images.jianshu.io/upload_images/4345694-cccf395a6649027c.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file
![](https://upload-images.jianshu.io/upload_images/4345694-b1fa2eda4573ba44.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

开启使用npm模块

![](https://upload-images.jianshu.io/upload_images/4345694-605c88977480955f.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

安装wx-server-sdk

![](https://upload-images.jianshu.io/upload_images/4345694-1262ba9205778d23.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

npm install --save wx-server-sdk@latest

![](https://upload-images.jianshu.io/upload_images/4345694-1bad861024701b3e.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

创建云函数

![](https://upload-images.jianshu.io/upload_images/4345694-9e791717c2646d9a.png?imageMogr2/auto-orient/strip|imageView2/2/w/514/format/webp)
file
        // 云函数入口函数
exports.main = async (event, context) => {
  console.log(event)
  console.log(context)
  return {
    sum: event.a + event.b
  }
}

本地调试云函数

![](https://upload-images.jianshu.io/upload_images/4345694-c38ebef0fc5a0e94.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file
![](https://upload-images.jianshu.io/upload_images/4345694-16b4774588701e01.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file
![](https://upload-images.jianshu.io/upload_images/4345694-f584b0c5c11d6aba.png?imageMogr2/auto-orient/strip|imageView2/2/w/1200/format/webp)
file

联系博主: blog.iffmd.cn/