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!