How to apply for WeChat applet development steps
How to apply for WeChat applet _ WeChat applet development tutorial, etc. In the past year, WeChat applet has finally been officially released. For developers and friends, you can apply to create your own applet in the future. So how to apply for WeChat applet? The following small series will share in detail the actual development tutorial of a WeChat applet from scratch, hoping that the operation steps will be helpful to the initial developers.
development steps of wechat applet
preparation before wechat applet application:
first, you need to register an applet account. You need to register with an email address that has not been registered in WeChat official account. The registration process requires a lot of authentication, which is complicated. If you just test the water for the time being and have no plans to publish it, you only need to fill in the basic information, and you don't need to complete WeChat authentication.
after that, you can log in with your registered account on the public platform.
then, click settings in the list on the left of the main page, and then select development settings in the settings page to see AppID. AppID can be used to register in the development tool and use the advanced functions of the development tool. You can download the development tools in official website.
Start a project:
Open the developer tool, select the applet option, and then click the "Add Project" button directly. In this step, we can fill in the AppID used when we just registered.
if the file in the project directory is an empty folder, you will be prompted whether to create a quick start project.
if you select "yes", the developer tool will help us generate a simple Demo in the development directory.
this Demo has a general framework of a complete applet.
1. Framework
First, let's take a look at the official Demo directory:
app.js: applet logic, life cycle, global variables.
app.json: applet public settings, navigation bar color, etc., and cannot be commented.
app.wxss: The applet is in a * * * style, similar to CSS.
The composition of applet pages is similar to this:
Each applet page is composed of four different suffix files with the same name under the same path, such as: index.js, index.wxml, index.wxss, index.json
The path and page file name of each page in WeChat applet need to be written in pages of app.json, and the first one in the pages array.
these four files can be divided into three parts according to their functions:
configuration: json file
logic layer: js file
view layer: wxss.wxml file
on iOS, the logic code of applet runs in JavaScriptCore, while on Android, this task is handed over to X5 kernel.
on the development tool, the JavaScript code of the applet runs in NW.js(Chrome kernel). This also leads to the difference between the effect of development tools and the actual effect.
2. Components
WeChat provides many components, which are mainly divided into eight types:
Among them, it includes common components such as view, scroll-view, button and form, and also provides mapcanvas
components, which mainly belong to the view layer, and are structured and laid out through WXML, similar to HTML. Styles are defined and modified by WXSS, and its syntax and usage are similar to CSS.
Examples of syntax used by components:
3. API
Network
Media
Data
Device
Interface
Development Interface
The network request interface contains common HTTPS requests and supports uploading, downloading and Socket, which basically meets the network requirements we need in development.
these APIs belong to the logic layer and are written in the JS logic file.
use example:
wx.getLocation({ type: 'wgs84', Success: function (res) {var latitude = res.latitude var longitude = res.longitude var speed = res.speed var accuracy = res.accuracy}})
You can check the usage of other APIs in the official document–API.
compile and run
1. Simulator debugging
We can use the simulator to check the effect of applet running in the developer tools provided by WeChat.
As we mentioned before, the applet runs at a different bottom level, which also leads to the effect on the simulator, which is somewhat different from that on the mobile phone.
2. real machine debugging
in the option bar on the left, select an item, and then click preview to produce a QR code. You can see the actual effect on the real machine by scanning it with the administrator's micro signal.
actual combat: running applet
screenshot of real machine running (running on iPhone 7, WeChat version: 6.3.31):
First, realize a timer to time, get coordinates through wx.getLocation, store the obtained coordinates in an array, get mileage through coordinates at regular intervals, accumulate to get the total mileage, and also connect through coordinate points. Existing problems:
Because there is no way to draw lines on the map at present, little red dot map is pasted on the map to show the approximate running path, which is rough;
although the Martian coordinate GCJ12 in API is adopted, the obtained coordinates are similar to the international coordinates, and there are still deviations.
I've put all the code on GitHub, so you can download it or Star it first, and I'll make some optimization updates in the future. Now it's just a learning Demo. Everyone communicates and learns, and the practical application needs more optimization.
(1)
(81)
Share
User comments
Pass registration |QQ Weibo Taobao WeChat
Modify the avatar
Note: All comments will not be made public until they are approved.
emoticon @ author comments
No comments, come and grab the sofa!
Related content
How to apply for WeChat applet development steps is introduced. How to make a WeChat applet How to enter WeChat applet How to enter WeChat applet Graphic tutorial How to register WeChat applet How to register WeChat applet How to register WeChat applet How to register WeChat applet How to register WeChat applet How to set WeChat applet payment notification settings. Methods How to apply for Alipay applet public beta qualification is introduced in detail. How to use WeChat applet? What is WeChat applet? How to use WeChat applet? How to find WeChat applet? < P > Latest article < P > What should I do if p>Win11 app store can't connect to the internet? Solution: Computers can't enter the system only when the cursor flashes in the upper left corner. Solution Press f1 to enter the system What should I do when the computer is turned on Press F1 to enter the system Solution Win11 Blue Screen Code memory management What should I do if Win11 can't enter Chinese Solution Win11 can't enter Chinese How can I solve Win11 without effective ip configuration How can I solve Win11 effective ip configuration method Win11 computer boot prompt "no bootable Solution of "device" What if you can't connect to the Internet after the network reset? Solution of Win11 can't connect to the Internet after the network reset What if Win11 can't update? Solution of Win11 error code 1x81241fff What if the computer mouse gets stuck intermittently? Causes and solutions
Latest update column
| Office software tutorial area | Computer question area | Network vocabulary encyclopedia | 12316 Encyclopedia |camera361 Zone | Super Curriculum Zone | Douban FM Zone | JD.COM Net Zone | Beauty Shooting Zone | Momo Zone | Netease Cloud Music Zone | Yixin Zone |Win11 Zone | Online Shopping Problem Skills Zone | Baidu Input Method Zone | Youku Zone |Linux Zone | Thunder Fast Transmission Zone |YY Voice Zone |361 Mobile Assistant Zone |361 Cloud Disk Zone |PPS Audio and Video Zone. Baidu Cloud Zone |Win8.1 Zone | Lacarra Zone | Computer Problem Zone | Alipay Zone | Baidu Zone | Taobao Zone
IT Hot Words
WeChat public platform login Haima Apple Assistant Alipay cash withdrawal fee? Alipay transfer fee? How to send the router address by WeChat group? How to reinstall the computer system? My world box ding ding about the car watermelon player fork assistant official website funny live broadcast Guobao Penguin esports
Everyone is searching
Is the mobile phone number positioning accurate? How to locate the mobile phone number? Is the location of mobile phone number accurate? Do you fool people in the name of "people"? The way of this APP is a bit wild. Spring digital big price scanning code is more favorable to enter the group. Put down your mobile phone! It may be as dangerous as you don't wear a mask. The advertisements of these platforms that you love to visit after 91 have been arranged.