In general, a parent component cannot change the style of a child component, so it takes some effort to do so.

Js / / component
Component({
  externalClasses: ['parent-class']});/ / WXML components
<view class="parent-class"></view>

// The parent page WXML
<w-more-img parent-class="parentClass"/>

// ***** The class name cannot use the hump, otherwise it will not take effect *****
Copy the code

If you want to override properties in a child component, you need to use! important

.parentClass{
  background: red! important;
}
Copy the code