Micro letter applet cloud development is not entirely refers to the North

Micro letter applet cloud development is not entirely refers to the North

We must first explain the development of the cloud, "cloud" is not a cloud in the cloud players of similar meaning, but the program is really small micro-channel provides a cloud development and virtual interfaces provide a simple background storage, database services (for some lightweight applets do not need a self-built server).

The authors also only just made a small micro-channel program, what problems can discuss together. (In fact, for small programs do not cloud development also curious, because the cloud is actually developed a kind of fool-key feel resolved).

This blog just to make a statement against a number of key steps in the hope that beginners can quickly get an overall impression of detail, please refer to the official documentation .

Registered Developer account

Registered Address: https://mp.weixin.qq.com/wxopen/waregister?action=step1

Download developer tools

Download: https://developers.weixin.qq.com/miniprogram/dev/devtools/download.html
recommended that you download a stable version.

Create a new cloud development project

Open the Developer Tools, fill in the project name and storage path, select cloud development, registration or use of a appid test number. appid to bind a mailbox, note that each can only bind a mailbox appid, test number, which means that only the use of development and testing, on-line can not (and can not seem to use cloud development function).


Introduction Framework

Directory Structure

After using the new applet and appid open, automatically generates a simple frame, a directory structure is as follows:



Which, app.js file contains the contents of the applet to be executed when loaded (initialization framework for cloud environment), app.json record page information as well as some of the content of pages outside of this small program (such as a small program used by its title the format).


Notes that there are two outer compare directory where the file wxss wxss file miniprogram / style of a page with, non-Musts under miniprogram, in fact, I do not know why, suggesting that only a global configuration, local configuration will not find this file to the default settings when looking for appropriate settings.

The other two files in the path miniprogram folders, image is well understood, the need to store image files page (frequent load the image file will exist here, will follow the code as part of a small program with on-line), pages specific store page information, each page of the pages has the following structure



Wherein the code file js i.e. when the page is loaded to be executed, JSON local configuration file belongs, it will be defined herein as a configuration of the current page in the current page before app.json coverage, the actual contents of the page that is displayed wxml (use html artifact turn wxml ), i.e. the current page wxss stylesheet files used can be defined in this position may be introduced before wxss file in the style.

Cloud Development

There are eye-catching cloud development tools button on the top left corner of the developer, simply click to enter the back-end micro letter provided



Json database is a simple database, only an administrator can add data directly from the background.

Cloud function

Cloud database development provided there is strict access restrictions, in general, to allow the user to modify the contents of the database, then you need to define cloud function as a bridge. Cloud function is actually stored in the cloud development environment, but can quickly browse locally, in cloudfuntions directory. You need to deploy to the cloud to take effect after each function to create a new cloud.
Here I talk about a problem encountered in coding, all changes to the database via the cloud function method that I found is as follows:

exports.main = async(event, context) => {
  return await db.collection('todos').add({
    data: {
      description: event.description,
      due: event.due
    }
  })
}

But I have a similar prompt much less a comma such errors parenthesis (unexpected what was it), to solve a variety of ways to no avail, will return back to delete await, the program runs as usual.

release

Click to release developer tools in the toolbar above the current applet can be published as a trial version, trial version is only available to users with limited experience, trial version can be submitted for review (very fast, half a day), review the version passed before making a formal posted on-line.

to sum up

整体来说微信小程序的云开发还是比较容易上手的,如果做过前段,熟悉js,那要掌握小程序云开发可以说是相当容易了。这种不需要自建后台的开发方式,很适合轻量级小程序使用,类似不需要自建后台的开发方式还有api工厂提供的方法。
总的来说,数据库使用云开发中的json数据库,云存储由云开发提供,用户鉴权和微信登录统一,对数据库的操作在云函数中定义,wxml和wxss文件可以通过html和css转化,相信没多少基础的的人也能很快上手微信小程序的云开发。

Guess you like

Origin www.cnblogs.com/thechosenone95/p/11032422.html