当前位置:网站首页>Uni app change the default component style

Uni app change the default component style

2022-07-05 03:59:00 Summer is already slightly cool

One 、 explain

  • uView file Checkbox Check box

  • vue After component compilation , Will template For each element in the [data-v-xxxx] Attribute to ensure that style scoped Only the elements of this component will not pollute the global

  • Arrange horizontally without wrapping , as follows
     Insert picture description here

  • Add style flex-wrap: wrap;, Line wrap successful
     Insert picture description here

Two 、 solve

1、 stay class front Join in deep

  • If you expect to pass such as modifying its son class The style of . To affect the display effect , Directly increase class There is no effect
  • You need to modify the specified component style class front Join in deep Can only be
<style lang="scss" scoped> /deep/ .u-checkbox-group--row{
    
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
}
</style>

2、 stay vue-cli3 Compile time , use ::v-deep

  • stay vue-cli3 Compile time ,deep An error will be reported or a warning will be given , We use it ::v-deep
<style lang="scss" scoped> ::v-deep .u-checkbox-group--row{
    
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
}
</style>

3、 Before editing , Edit well Screenshot comparison

  • Before editing
     Insert picture description here
  • After editing
     Insert picture description here

3、 ... and 、 His shan zhishi

原网站

版权声明
本文为[Summer is already slightly cool]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202140717516053.html