Applet component appears Some selectors are not allowed in component wxss ...

 

Component styles

Components corresponding to the  wxss style file, only the entry into force of nodes within the assembly wxml. When writing style components, note the following:

  • Page components and reference to the component can not use the id selector ( #a), attribute selectors ( [a]) and tag name selector, use the class selector.
  • Page components and assemblies used in reference descendant selectors ( .a .b) in some extreme cases, there will be unexpected performance, such as the case, please be avoided.
  • Child element selector ( .a>.b) can only be used  view between the component and its child node, the other components may lead to unintended.
  • Inheritance pattern, such as  font , color will inherit from the outer component into the assembly.
  • In addition to inheriting style, the  app.wxss style in the style of the page where the assembly of custom components is not valid (unless you change the style component isolation option).

 

This happens Solution:

/* 组件 custom-component.js */
Component({
  options: { addGlobalClass: true, } })

Guess you like

Origin www.cnblogs.com/lovelh/p/11853048.html