当前位置:网站首页>[wechat applet] global style, local style, global configuration
[wechat applet] global style, local style, global configuration
2022-07-25 07:32:00 【Su liang.py】
Author's brief introduction : Su Liang ( Focus on web crawlers , Data analysis , On the way to learning the front end )
Blog home page : Su Liang .py The blog of
Series column : Basic course of applet development
Aphorisms : The sea is wide with fish , The sky is high and the birds are flying .
If you think the blogger's article is good , I hope you can support me for the third time in a row !!!
Follow the likes collection
List of articles
Style import
Use wxss Provided @import grammar , You can import an external style sheet .
@import grammar
@import Followed by the relative path of the external stylesheet to be imported , use ; End of statement .
example :
- Create a folder in the root directory , Create one in the folder
wxssfile
- In the wxss Write down style , And in page wxss Import the style into the file .

In this way, you can import the outreach style .
Global style
The global style is app.wxss This file , The styles in this will be applied to the overall situation . For every page .

Local style
In the page .wxss Files belong to local styles , Only works on the current page .
Be careful :
- When a local style conflicts with a global style , according to Nearby principle , Local styles override global styles
- When the weight of the local style is greater than or equal to the weight of the global style , Will override the global style
Global configuration
In the applet root directory app.json File is the global configuration file of the applet . Common configuration items are as follows :
- pages
Record the storage path of all pages of the current applet - window
Set the appearance of the applet window globally - tabBar
Set the at the bottom of the applet tabBar effect - style
Whether to enable the new component style
The window component of the applet
window The navigation bar area and background area of the applet can be configured .

Global configuration –window
Commonly used window Configuration properties
| Property name | type | The default value is | explain |
|---|---|---|---|
navigationBarTitleText | String | character string | Navigation bar title text content |
navigationBarBackgroundColor | Hexcolor | #000000 | Navigation bar background color , Such as #000000 |
navigationBarTextStyle | String | white | Navigation bar Title Color , Support only black / white |
backgroundColor | Hexcolor | #ffffff | Background color of window |
backgroundTextStyle | string | dark | The drop-down loading The style of , Support only dark / light |
enablePullDownRefresh | Boolean | false | Enable pull-down refresh globally |
onReachBottomDistance | Number | 50 | Distance from the bottom of the page when the pull-up event is triggered , Unit is px |
stay app.json Found in file window To configure .
Such as : Modify the title and background color of the navigation bar .

Turn on pull-down refresh
Pull down refresh is a proper term for mobile terminal , It refers to the pull-down and sliding operation of your finger on the screen , To reload page data .
stay window Under global configuration , take enablePullDownRefresh Property value changed to true that will do .

stay app.json After the pull-down refresh is enabled in, it will work on every page .
Set background color :
Set up loading style :
This can only be set to dark and light Two styles .

Set the pull-up distance to the bottom
Pull up to touch the bottom is a proper term for mobile terminal , Pull up and slide the screen with your fingers , So as to load more data .
The default distance is 50px, To reset , It's in app.json In the document window Item to configure .
Global configuration –tabBar
tabBar It is a common page effect in mobile applications , It is used to realize the fast switching of multiple pages . Small programs are usually divided into :
- Bottom tabBar
- Top tabBar
Be careful :
- tabBar You can only configure least 2 individual 、 most 5 individual tab Tab .
- When rendering top tabBar when , No display icon, Show only text .
tarBar Of 6 Components
backgroundColor: tabBar Background color of
selectedlconPath: The path of the selected image
borderStyle: tabBar The color of the top border
iconPath: Picture path when not selected
selectedColor : tab The color of the selected text on
color: tab The default of the text on ( Not selected ) Color
tarBar Configuration item of node
| attribute | type | Required | The default value is | describe |
|---|---|---|---|---|
| position | String | no | bottom | tabBar The location of , Support only bottom/top |
| borderStyle | String | no | black | tabBar The color of the top border , Support only black/white |
| color | HexColor | no | tab The default of the text on ( Not selected ) Color | |
| selectedColor | HexColor | no | tab The color of the selected text on | |
| backgroundColor | HexColor | no | tabBar Background color of | |
| list | Array | yes | least 2 individual 、 most 5 individual tabtab List of tabs . |
Every tab Configuration item of item
stay app.json Added to window Flush tabBar Configuration item .
Among them, every tab Items have the following four attribute values .
| attribute | type | Required | describe |
|---|---|---|---|
| pagePath | String | yes | Page path , The page must be in pages Predefined in |
| text | String | yes | tab Text displayed on |
| iconPath | String | no | Icon path when not selected ; When postion by top when , No display icon |
| selectedlconPath | String | no | Icon path when selected ; When postion by top when , No display icon |

边栏推荐
- How to use network installation to deploy multiple virtual servers in KVM environment
- 9 best engineering construction project management systems
- Teach you to use cann to convert photos into cartoon style
- Load capacity - sorting out the mind map that affects load capacity
- Problems during nanodet training: modulenotfounderror: no module named 'nanodet' solution
- 【ES6】函数的参数、Symbol数据类型、迭代器与生成器
- 第一启富金怎么样
- Servlet常用类剖析
- 【Unity入门计划】制作我的第一个小游戏
- "Game illustrated book": a memoir dedicated to game players
猜你喜欢

Introduction to cesium

Million level element optimization: real-time vector tile service based on PG and PostGIS

钉钉最新版,怎么清除登录手机号历史记录数据

Luo min's backwater battle in qudian

Teach you to use cann to convert photos into cartoon style

北京内推 | 微软STCA招聘NLP/IR/DL方向研究型实习生(可远程)

Problems in deep learning training and testing: error: the following arguments are required: --dataroot, solution: the configuration method of training files and test files

Luo min from qudian, prefabricate "leeks"?

9大最佳工程施工项目管理系统

12 combination methods and risk interpretation of database architecture optimization (books available)
随机推荐
When providing digital talent services, Xi Zhi quickly opened its own digital school for each organization
LeetCode118. 杨辉三角
【Unity入门计划】基本概念-触发器 Trigger
【Unity入门计划】界面介绍(2)-Games视图&Hierarchy&Project&Inspector
Leetcode skimming: dynamic programming 06 (integer splitting)
数据提交类型 Request Payload 与 Form Data 的区别总结
Pads export Gerber file
北京内推 | 微软STCA招聘NLP/IR/DL方向研究型实习生(可远程)
冰冰学习笔记:类与对象(上)
What are the types of financial products in 2022? Which is suitable for beginners?
UXDB怎么从日期值中提取时分秒?
9 best engineering construction project management systems
一日千里,追风逐月 | 深势科技发布极致加速版分子对接引擎Uni-Docking
"Game illustrated book": a memoir dedicated to game players
Gan series of confrontation generation network -- Gan principle and small case of handwritten digit generation
Price reduction, game, bitterness, etc., vc/pe rushed to queue up and quit in 2022
【Unity入门计划】制作我的第一个小游戏
Analysis of difficulties in diagramscene project
Luo min's backwater battle in qudian
Teach you to use cann to convert photos into cartoon style