当前位置:网站首页>自定义组件--样式
自定义组件--样式
2022-07-28 05:25:00 【像费曼%】
1.默认情况下,自定义组件的样式只对当前组件生效,不会影响到组件之外的UI结构,如图所示:
- 组件A的样式不会影响组件C的样式
- 组件A的样式不会影响小程序页面的样式
- 小程序页面的样式不会影响组件A和C的样式

2.组件样式隔离的注意点:
- app.wxss中的全局样式对组件无效
- 只有class选择器都会有样式隔离效果,id选择器、属性选择器、标签选择器不受样式隔离的影响
- 建议:在组件和引用组件的页面中建议使用class选择器,不要使用id、属性、标签选择器
3.修改组件的样式隔离选项
默认情况下,自定义组件的样式隔离特性能够防止组件内外样式互相不干扰的问题,但有时,我们希望外界能够控制组件内部的样式,此时,可以通过styleIsolation修改组件的样式隔离选项,用法如下
//在组件的.js文件中新增如下配置
Component({
options:{
styleIsolation:'isolated'
},
styleIsolation的可选项:
| 可选框 | 默认值 | 描述 |
| isolated | 是 | 表示启用样式隔离,在自定义组件内外,使用class指定的样式将不会影响 |
| apply-shared | 否 | 表示页面wxss样式将影响到自定义组件,但自定义组件wxss指定的样式不会影响到页面 |
| shared | 否 | 表示页面wxss样式将影响到自定义组件,自定义组件wxss中指定的样式也会影响到页面和其他设置了apply-shared或shared的自定义组件 |
边栏推荐
- Efficient Net_ V2
- How to test industrial Ethernet cables (using fluke dsx-8000)?
- Design and analysis of contactor coil control circuit
- 【学习笔记】链表操作
- Machine learning note 5 - logistic regression
- What about the insufficient memory of Clickhouse aggregation? Then improve the polymerization performance
- 【学习笔记】线程创建
- error: redefinition of ‘xxx‘
- 自定义组件--纯数据字段&组件的生命周期
- OpenGL的开发环境配置【VS2017】+常见问题
猜你喜欢

Bag of tricks training convolution network skills

基于 YOLOV5 的 SAR 图像舰船检测

Five categories of IP addresses

EfficientNET_ V1

Shuffle Net_ v1-shuffle_ v2

IP地址的五大分类

ICC2(三)Clock Tree Synthesis

Detailed explanation of word mail merge function: after merging, multiple word documents are generated and blank pages are deleted

Trouble encountered in cable testing -- a case study of a manufacturer?

Bert bidirectional encoder based on transformer
随机推荐
基于 YOLOV5 的 SAR 图像舰船检测
Detailed explanation of word mail merge function: after merging, multiple word documents are generated and blank pages are deleted
VI and VIM commands
EMC experiment practical case ESD electrostatic experiment
IP地址的五大分类
Pytorch learning notes 3 - datasets & dataloaders & transforms
PyTorch 学习笔记
论文神器 VS Code + LaTex + LaTex Workshop
【学习笔记】编码能力
set_multicycle_path
qt绘画事件-设置背景图片
MATLAB signal processing
Esxi on ARM v1.2 (updated in November 2020)
MySQL delete tables without deleting databases
set_ clock_ groups
新的selenium
I heard that you are also practicing when I interviewed several junior interns.
Perl Introduction (10) formatted output
IMS-FACNN(Improved Multi-Scale Convolution Neural Network integrated with a Feature Attention Mecha
Five categories of IP addresses