Cloud development learning documentation

I. Project initialization

1. After the registration number applet, the new project will not use the test number, but use the cloud development with ID

2. After creating the project, delete unnecessary configuration items, including redundant page of cloud functions, leaving only one index page



3. Delete unnecessary page configuration in app.json, leaving only index, delete common CSS, other configuration need not change

4, Delete the index HTML CSS JS reconfigure when configuring JS using the second option in page as shown in the figure below



The effect of js configuration is shown in the following figure:

Second, use cloud console to control the database



Table data can be created. Click Add Record:



There are seven data types:

Third, display the contents of the database on the page

Permission control:



It is better to change to the following option:



Here’s how to add, delete, change and check the database:

Official Learning Document

There are the following learning steps:



Mysql > initialize database;

const db = wx.cloud.database()
Copy the code



2, call function link database:



SQL > query doc data



HTML page rendering:



If you want to render more than one data table, you can remove the table selected by doc:

Here it is:

Get calls all data and loops:



Page rendering data: WX “for” rendering:

You can only put fields in doc, you can’t put anything else. Where gets an array. If you know one of these values, you can put back an entire array.

Insert data into the database

Two ways:



Promise:





Check the success of the increment in the database:

Note that the point is to click on the content to add once, now this will not be solved, back to write

Print it in the console to see if it works:



Successful printing:



Solve one click load. Questions that will not be repeated.

1. Add wx.loading: to the addData function, as shown in the figure



2. Join wx.hideLoding at the end:

After loading, it automatically disappears:

Submit the form to add to the database

Using forms

Define structure and style:



Write behavior in js:



So let me do that. The test on the back is gone