WeChat applet: basic use of components

Source: Internet
Author: User
Today, we will introduce in detail the basic usage of small program components. First, create a new page, which is unclear about the basic directory structure of the applet. you can view it in our series of tutorials. 1) create a directory (named newvip). today we will introduce in detail the basic usage of Applet components.
First, create a new page, which is unclear about the basic directory structure of the applet. you can view it in our series of tutorials. 1) create a directory (named newvip );
2) add newvip under the project. js and newvip. wxml. (We have introduced the following in the previous tutorial :. js and. wxml is an essential two files for creating pages ).
3) register the newly added page in app. json as follows:

  "pages":[    "pages/newvip/newvip",    "pages/index/index",    "pages/logs/logs"  ],

4) at this time, compilation is definitely not successful. (You may wish to try it and be more impressed ). We also need to write the basic page content on the newvip. js page. of course, we only need to enter the page and it will pop up automatically. we can use the default page content first.

Page ({data: {String1}, onLoad: function (options) {// Life cycle function -- listen to the Page to load String2}, onReady: function () {// Life cycle function -- listener page first rendered String3}, onShow: function () {// Life cycle function -- listener page display String4}, onHide: function () {// Life cycle function -- listener page hide String5}, onUnload: function () {// Life cycle function -- listener page unload String6}, onPullDownRefresh: function () {// page-related event processing function -- listen to the user drop-down action String7}, onReachBottom: function () {// The processing function String8} of the bottoming event on the page, ondeskappmessage: function () {// the user clicks share return {title: 'title' in the upper right corner, // share the title desc: 'desc', // share the description path: 'Path' // sharing path }}})

5) The editing will pass. Enter some text on the newvip. wxml page, as shown in:

We can see that there are many components. in the previous article mini-program: view container, we also briefly introduced the components of mini-programs. In fact, the code used by all components is provided in the official documentation of the applet components. we can simply copy and modify the code to use it. next we will take the button as an example. We copied the following content from the official documentation of the mini-program:

 default  primary 

Of course, some of them are not convenient for the time being. we will delete the most basic content, as shown in after compilation:

More small programs: for the basic usage of components, please follow the PHP Chinese network!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.