search
HomeWeChat AppletMini Program DevelopmentWeChat Mini Program Development Series (2) Detailed explanation of the use of development components

This article introduces the WeChat applet development series (2) Detailed explanation of the use of development components

1: Preliminary use of development components

1: Establishing a WeChat applet project


2: Please refer to the content in the following link, which is the official development guide for WeChat mini programs:

https://mp.weixin.qq.com /debug/wxadoc/dev/component/button.html?t=20161222


3: You can copy some example programs to the project you created using WeChat The components of the applet are shown in Figure 1:

We can write the layout of the first page in first.wxml. For example, in Figure 1 we wrote a string: "1234567890abcdefg", below this character We wrote a button for a WeChat applet. The content displayed by the button is "default", type="default"---this means that the button has the default display effect, as shown in the simulator on the left side of Figure 1 with rounded corners. Gray buttons have no borders on the left and right sides.

Note: Many netizens will find that after writing the code in the WeChat Mini Program Development Tool and clicking the "Compile" button on the left side of the WeChat Mini Program Development Tool, there is no response in the simulator. In fact, this This is because after you write the code, you should hit Ctrl+s on the keyboard, save the code, and then click "Compile" so that the effect of the corresponding code can be displayed in the simulator.

 微信小程序开发系列(二)详解

Figure 1

4: Binding of button display content and click event:

We implement a function below: after clicking the button , replace the content of the button with new content

1) Add the following code to first.wxml: bindtap="btnClick" is the method for binding the click time of the button: btnClick(), {{btnText}} Variable bound to the content displayed by the button: btnText


2) Method: btnClick() and variable: btnText must be implemented in first.js, as shown in Figure 2

 微信小程序开发系列(二)详解

Figure 2

3 ) Before and after clicking the button, the simulator display effect is shown in Figure 3:

 微信小程序开发系列(二)详解

Figure 3

5: Preliminary use of text component:

We implement a function below: after clicking the button, modify the initial content of the text component, then click the button again, the text component content disappears, and then click the button again, the text component content appears. . . . . . And so on.

1) Add the following code to first.wxml:

{{text}} text>

Add the code shown in Figure 4 to first.js

 微信小程序开发系列(二)详解

##Figure 4


##6: Content list



Add the following code to first.wxml:


{{index}}: {{newsItem}}





Add the following code to first.js


data:{ }

:


news:[' 1 line of information','2nd line of information','3rd line of information']


The result is shown in Figure 5:

 微信小程序开发系列(二)详解 Figure 5

7: Add header and footer to the page


Create a new folder templates, and create new files under the folder: footer.wxml and header.wxml

Add the code shown in Figure 6 to the file

 微信小程序开发系列(二)详解Figure 6

The simulator displays the result as shown in Figure 7

 微信小程序开发系列(二)详解2: WeChat applet configuration

Here we explain the APP page configuration, window configuration, tabBar configuration, network configuration and other information

As shown in Figure 1 and Figure 2 Show:

 微信小程序开发系列(二)详解

figure 1

 微信小程序开发系列(二)详解


The above is the detailed content of WeChat Mini Program Development Series (2) Detailed explanation of the use of development components. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment