微信云开发怎么搭建源码小程序

抖音小程序 2023-12-30 12:15:14 38
微信云开发:如何搭建源码小程序
1. 准备工作

在开始搭建源码小程序之前,请确保您已经具备以下条件:

  1. 注册一个微信公众平台账号;(https://mp.weixin.qq.com/)
  2. 注册一个云开发环境;(https://developers.weixin.qq.com/miniprogram/dev/devtools/cloud/)
  3. 安装并配置开发者工具;(https://developers.weixin.qq.com/miniprogram/dev/devtools/desktop/)

微信云开发怎么搭建源码小程序

2. 创建云开发项目

打开开发者工具,点击“新建项目”,然后选择“云开发”。填写项目名称、AppID、AppSecret等信息,点击创建。

3. 搭建项目结构

创建完成后,项目结构如下:

                 ├── cloudfunctions
                 │   ├── app.js
                 │   ├── app.json
                 │   ├── app.wxss
                 │   ├── pages
                 │   │   ├── index
                 │   │   │   ├── index.js
                 │   │   │   ├── index.json
                 │   │   │   ├── index.wxml
                 │   │   │   ├── index.wxss
                 │   ├── utils
                 │   │   ├── util.js
                 │   ├── app.json
                 ├── package.json
                 ├── readme.md
                 └── .gitignore
             

4. 编写页面代码

打开index页面的index.wxml,编写页面结构如下:

                 <view  class="599f-90bc-3444-3937 container">
                      <view  class="90bc-3444-3937-5b8d title">欢迎使用微信云开发</view>
                      <view  class="521e-71c0-facd-6e68 content">
                          <button  bindtap="getUserInfo"  class="71c0-facd-6e68-c526 btn">获取用户信息</button>
                      </view>
                 </view>
             

5. 编写页面样式

打开index页面的index.wxss,编写页面样式如下:

                 .container  {
                      display:  flex;
                      flex-direction:  column;
                       align-items:  center;
                      justify-content:  center;
                      height:  100%;
                 >
The End