欢迎访问百里百科

微信小程序开发注册全流程解析,从创建到发布一应俱全

频道:微信小程序商城 日期: 浏览:9173
微信小程序开发注册全流程解析,从创建到发布一应俱全。以下是微信小程序上线流程,包括微信小程序账号注册开通、填写小程序信息、认证、开发小程序、小程序提交审核和发布全过程 。在微信开发者工具中,选择“新建项目”,填写小程序的 AppID(在注册开发者账号时可以获取到),以及项目名称、目录等信息,就可以创建一个新的小程序项目了。

随着移动互联网的快速发展,微信小程序已经成为了开发者们获取用户的主要途径之一,如何进行微信小程序的开发注册呢?本文将为您详细解析微信小程序开发的全流程,从创建到发布一应俱全,帮助您快速上手微信小程序开发。

微信小程序注册

1、注册微信公众平台账号

您需要注册一个微信公众平台账号,访问微信公众平台官网(https://mp.weixin.qq.com/),使用邮箱或手机号进行注册,完成注册后,登录微信公众平台,进入“管理中心”页面。

微信小程序开发注册全流程解析,从创建到发布一应俱全

2、开通小程序

在微信公众平台的“管理中心”页面,选择“小程序”选项,然后点击“进入小程序管理”按钮,按照提示完成小程序的开通流程,需要注意的是,您需要确保您的微信公众号已经通过了微信认证,否则无法开通小程序。

3、填写小程序信息

在开通小程序时,您需要填写小程序的基本信息,包括名称、简介、头像等,您还需要选择小程序的类型(如企业、政府、媒体、其他组织等)、所在地区以及行业分类,请根据您的实际情况进行选择。

4、提交审核

在填写完小程序信息后,您需要提交小程序的审核,微信团队会对您提交的小程序进行审核,审核通过后,您的小程序即可正式上线,小程序的审核时间可能会有所不同,一般需要等待几天至一周左右。

微信小程序开发注册全流程解析,从创建到发布一应俱全

微信小程序开发环境搭建

在完成微信小程序的注册和开通后,您需要搭建一个适合开发微信小程序的开发环境,以下是搭建微信小程序开发环境的步骤:

1、安装Node.js

您需要安装Node.js,访问Node.js官网(https://nodejs.org/),根据您的操作系统下载并安装相应的Node.js版本,安装完成后,打开命令行工具,输入以下命令检查Node.js是否安装成功:

node -v

2、安装npm

Node.js自带了一个包管理器npm,通常情况下,您无需额外安装npm,如果npm未被识别,请访问npm官网(https://www.npmjs.com/get-npm)下载并安装适用于您的操作系统的npm版本。

3、全局安装wepy-cli

微信小程序开发注册全流程解析,从创建到发布一应俱全

wepy-cli是一个基于Vue CLI的项目脚手架工具,可以帮助您快速搭建微信小程序项目,在命令行工具中输入以下命令全局安装wepy-cli:

npm install -g wepy-cli --registry=https://registry.npm.taobao.org

4、创建微信小程序项目

安装好wepy-cli后,您可以使用它来创建一个新的微信小程序项目,在命令行工具中输入以下命令:

wepy create <project-name> --type weapp --platform alipay --template miniprogram-template

<project-name>是您要创建的项目名称,执行该命令后,wepy-cli会自动下载并安装所需的依赖包,以及创建一个包含基本代码结构的微信小程序项目。

微信小程序开发教程

1、初始化项目结构

在创建好微信小程序项目后,您需要初始化项目的目录结构,打开项目根目录下的package.json文件,修改其中的scripts字段,添加以下内容:

微信小程序开发注册全流程解析,从创建到发布一应俱全

"scripts": {
  "start": "wepy build", // 构建生产环境代码
  "dev": "wepy dev", // 启动开发环境服务
  "build": "wepy build", // 构建生产环境代码并预览效果(生产环境必须先 build)
  "test": "wepy test" // 用测试覆盖率工具生成报告(运行前需先 install mocha) (生产环境必须先 build) (暂不支持)"
}

2、编写业务代码

在完成项目的初始化后,您可以开始编写业务代码,微信小程序采用MVVM架构,您可以根据自己的需求选择合适的前端框架(如React、Vue等),在项目根目录下创建一个名为.env的文件,配置您的开发环境变量:

NODE_ENV=development # development or production environment (default is development)
WEPY_APP_PROPERTIES=/path/to/your/miniprogram.json # miniprogram app config file path (required for miniprogram app) (default is none) if you use wepy-quickstart to init your project and do not change this default value in future; else set it manually as{ "site": "your site url" } in your own miniprogram app config file then wepy will auto read the value from it when you run the commandwepy dev; if you use miniprogram template to start a new project and do not change this default value in the future then wepy will use the value from/path/to/your/miniprogram.json, but if you use miniprogram template to start a new project and want to change this default value in the future then please set it manually as--app-config="/path/to/your/miniprogram.json". if you are using miniprogram quickstart to init your project and do not want to use--app-config="/path/to/your/miniprogram.json" then please do NOT set this variable because the default value of this variable isnone. if you want to use custom env variables then you can add your own env variables by addingWEPY_APP_PROPERTIES={"YOUR_CUSTOM_VARIABLES": "value"} to your.env file (for exampleWEPY_APP_PROPERTIES={"apiUrl": "https://api.example.com"}). note that you should not add any space between the curly braces{}. also note that you should not add any spaces after comma, or before colon: in your env vars string. e.g.WEPY_APP_PROPERTIES={"apiUrl": "https://api.example.com"} is correct whileWEPY_APP_PROPERTIES={"apiUrl": "https://api.example.com"} is incorrect and will cause errors later on during development and build process because there is an extra space after colon: which is required in env vars strings (if you need more information about how to configure your env vars please check the [official documentation](https://www.npmjs.com/package/dotenv)) # DO NOT REMOVE THIS LINE OR IT WILL CAUSE ERRORS ON BUILD AND DEVELOPMENT (it is used to detect whether the env file is loaded correctly) # DO NOT ADD ANY NEWlines BELOW THIS LINE # DO NOT REMOVE THIS COMMENT IF YOU NEED TO DEBUG YOUR APP WITH THE STAGER (it is used to detect whether the server is running correctly) (you can remove this line after you make sure that the server is running properly without this comment) WEPY_APP_PUBLIC=public # public folder where your app files are located (default is 'dist') WEPY_APP_INSTANCE_ID=yourInstanceId # instance id (default is '0') WEPY_APP_PAGE='pages/index/index' # entry page of the app (default is '/') WEPY_APP_SUB_PROCESS=true # enable sub processes support for Wepy CLI commands (default is false) WEPY_APIHOST=http://localhost:8080 # API host (default is 'http://localhost:8080') WEPY_APIPORT=8080 # API port (default is '8080') WEPY_APISSL=false # whether to use HTTPS (default is false) WEPY_APITOKEN='yourApiToken' # your API token for authentication (default is '') WEPY_AUTHDOMAIN='yourAuthDomain' # your authentication domain for WeChat Open Platform OAuth2 (default is '') WEPY_AUTHREDIRECTURL='yourAuthRedirectUrl' # redirect URL for WeChat Open Platform OAuth2 login flow (default is '/') WEPY_AUTHSCOPES='snsapi_userinfo' # scope of permissions needed for WeChat Open Platform OAuth2 login flow (default is 'snsapi_userinfo') WEPY_AUTHTYPE='oauth2' # type of auth provider (default is 'oauth2') WEPY_CALLBACKURL='/callback' # callback URL for WeChat Open Platform OAuth2 login flow (default is '/callback') WEPY_LANG='en' # locale of user interface language (default is 'en') WEPY_PLATFORM='web' # web platform (supported platforms: 'web' | 'miniprogram') WEPY_PROFILE='profile' # profile page route of the app (default is '/profile') WEPY_VERSION='1.0.0' # version of Wepy framework (default is '1.0.0') WEPY_VERBOSE='false' # verbose mode for Wepy CLI commands (默认为false); set true to show detailed logs during build and development process; set false to hide logs during build and

与本文内容相关的知识文章:

微信小程序怎么用?

微信小程序怎么不用流量(微信小程序怎么不用流量使用)

微信小程序怎么跳过(微信小程序怎么跳过300认证费)

微信小程序怎么返回微信界面(微信小程序怎么返回微信界面设置)

微信小程序怎么查看主题(小程序主体在哪看)