当前位置:网站首页>Basic knowledge of wechat applet cloud development literacy chapter (I) document structure
Basic knowledge of wechat applet cloud development literacy chapter (I) document structure
2022-06-24 06:34:00 【User 3004405】
File structure
Global file
app.js file
This is the script code file of the applet , You can listen on this file , And deal with some of the lifecycle of the applet ( For example, some global variables )
In this app.js In the file , Need to use App() function , To register the program .
demonstration :
//app.js
App({
onLaunch: function () {
// When applet initialization is complete , Will trigger onLaunch( Global trigger only once )
},
onShow: function () {
// When the applet starts , Or enter the foreground display from the background , Will trigger onShow
},
onHide: function () {
// When the applet enters the background from the foreground , Will trigger onHide
},
onError: function (msg) {
// When a script error occurs in an applet , perhaps api When the call fails , Will trigger onError With error message
},
other:function(){
// Global function , Can be used by others on the project js A file called
},
globalData:{
// Global object
},
})
app.json file
The global configuration file of the applet
pages
To specify which pages the applet consists of
Accept an array , Each item is a string . Each item represents the 【 route + file name 】 Information , The first item in the array represents the initial page of the applet . Add... To the applet / Reduce pages , All need to pages Array to modify .
The file name does not need to be suffixed , Because the framework will automatically find the path .json,.js,.wxml,.wxss To integrate the four files .
for example :
{
"pages":[
"pages/index/index",
"pages/logs/logs"
]
}
remarks :pages You just need to write wxml Path to file , Other documents do not need to be written
window
Status bar for setting up applets 、 Navigation bar 、 title 、 Window background color
Example :
{
"window":{
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": " Wechat interface function demonstration ",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}
}
tabBar
If our app is more than one tab application ( There is... At the bottom or top of the client window tab Column can switch pages ), Then we can pass tabBar Configuration item assignment tab Column performance , as well as tab The corresponding page displayed when switching .
Tip: Jump through the page (wx.navigateTo) Or page redirection (wx.redirectTo) The page arrived , Even if it is defined in tabBar Pages in configuration , The bottom... Will not be displayed tab bar .
tabBar Is an array , It can only be configured with a minimum of 2 individual 、 most 5 individual tab,tab Sort by array .
Example :
{
"tabBar": {
"color":"#818181",
"selectedColor":"#0082D7
"borderStyle":"white",
"list": [{
"pagePath": "pages/index/index",
"text": " home page ",
"iconPath":"images/tabbar/[email protected]",
"selectedIconPath":"images/tabbar/[email protected]"
}, {
"pagePath": "pages/me/me",
"text": " Set up ",
"iconPath":"images/tabbar/[email protected]",
"selectedIconPath":"images/tabbar/[email protected]
}]
}
}
networkTimeout
You can set the timeout of various network requests .
Example
{
"networkTimeout": {
"request": 10000,
"downloadFile": 10000
}
}
debug
It can be opened in developer tools debug Pattern , In the developer tool's console panel , Debug information to info Given in the form of , The message is Page Registration of , Page routing , Data update , Events trigger . Can help developers quickly locate some common problems .
Example :
{
"debug": false
}
app.wxss file
Define the global style
Basically with css almost , Not much here
Inside a page
xxx.js
Logical main function
Page({
})
Example :
//index.js
Page({
data: {
text: "This is page data."
},
onLoad: function(options) {
// Do some initialize when page load.
},
onReady: function() {
// Do something when page ready.
},
onShow: function() {
// Do something when page show.
},
onHide: function() {
// Do something when page hide.
},
onUnload: function() {
// Do something when page close.
},
onPullDownRefresh: function() {
// Do something when pull down.
},
onReachBottom: function() {
// Do something when page reach bottom.
},
onShareAppMessage: function () {
// return custom share data when user share.
},
// Event handler.
viewTap: function() {
this.setData(
text: 'Set some data for updating view.'
})
},
customData: {
hi: 'MINA'
}
})
Example :
Page({
onShareAppMessage: function () {
return {
title: ' Custom share title ',
desc: ' Custom sharing description ',
path: '/page/user?id=123'
}
}
})
xxx.wxml
Use the components provided by wechat to replace html Elements
Example :
xxx.wxss
Applet style , And css The style is basically similar , There is no repetition here
In the wxss Edited in the file css style , Can only be used on the current page
xxx.json
Every applet page can also use .json File to configure the window representation of this page . Page configuration ratio app.json Global configuration is much simpler , Just settings app.json Medium window Content of configuration item , Configuration items in the page will overwrite app.json Of window The same configuration item in .
Page .json Only... Can be set window Related configuration items , To determine the window performance of this page , So there's no need to write window This key
Example :
{
"navigationBarBackgroundColor": "#ffffff",
"navigationBarTextStyle": "black",
"navigationBarTitleText": " Wechat interface function demonstration ",
"backgroundColor": "#eeeeee",
"backgroundTextStyle": "light"
}
边栏推荐
- Skips allowed on SAP QM material master inspection type
- Operation and maintenance dry goods | how to improve the business stability and continuity through fault recovery?
- Micro build low code supports Excel to import data source
- Produce kubeconfig with permission control
- Introduction to QWidget attribute table in QT Designer
- How to give full play to the advantages of Internet of things by edge computing intelligent gateway
- How does easyplayer RTSP configure sending heartbeat information to the server?
- The three-year action plan of the Ministry of industry and information technology has been announced, and the security industry has ushered in major development opportunities!
- 【二叉数学习】—— 树的介绍
- Go current limiting component package rate source code analysis
猜你喜欢
Oracle case: ohasd crash on AIX

基于三维GIS系统的智慧水库管理应用

创客教育给教师发展带来的挑战

【二叉树】——二叉树中序遍历

Manual for automatic testing and learning of anti stepping pits, one for each tester

Technology is a double-edged sword, which needs to be well kept

The product layout is strengthened, the transformation of digital intelligence is accelerated, and FAW Toyota has hit 2022million annual sales

Enter the software test pit!!! Software testing tools commonly used by software testers software recommendations
Fault analysis | using --force to batch import data leads to partial data loss

ServiceStack. Source code analysis of redis (connection and connection pool)
随机推荐
Why the computer can't start
[fault announcement] one stored procedure brings down the entire database
The installation method of apache+mysql+php running environment under Windows
Flexible use of distributed locks to solve the problem of repeated data insertion
How does easyplayer RTSP configure sending heartbeat information to the server?
What is the domain name query network and how it should be used
SQL server memory management on cloud
Easyscreen live streaming component pushes RTSP streams to easydss for operation process sharing
PMP | 8 abilities that excellent project managers focus on training
I want to say "three no" to digital transformation
The influence of TLS protocol and cipher on remote RDP
Innovating the security service mode, deeply convinced that the organization has been equipped with a "continuous online expert group"
Excellent tech sharing | research and application of Tencent excellent map in weak surveillance target location
How to check whether the domain name is filed? Must the domain name be filed for use?
Talk about the story behind search engines
Microsoft Security, which frequently swipes the network security circle, gives us some enlightenment this time?
Implementation of code rate and frame rate statistics in easyplayer RTSP player
Skips allowed on SAP QM material master inspection type
When easynvs is deployed on the project site, easynvr cannot view the corresponding channel. Troubleshooting
Tencent launched the "reassuring agricultural product plan" to support 100 landmark agricultural product brands!