Differences in selector usage between WeUI and WeUI for 小程序
masterBecause WeChat Mini Programs (小程序) have limitations regarding certain CSS selectors, you cannot use standard Web WeUI patterns. Specifically, adjacent sibling selectors and descendant (cascading) selectors are not supported. Instead, you must use specific modifier classes to achieve the same styling.
Replacing Adjacent Sibling Selectors
Instead of using + (e.g., .weui-cells__title + .weui-cells), apply a specific modifier class directly to the target element.
- Pattern:
.weui-cells__title + .weui-cells$\rightarrow$.weui-cells_after-titleon the.weui-cellselement.
Replacing Descendant Selectors
Instead of nesting styles via parent-child relationships (e.g., .weui-cell_access .weui-cell__ft), apply a modifier class to the child element that indicates its context.
- Pattern:
.weui-cell_access .weui-cell__ft$\rightarrow$.weui-cell__ft_in-accesson the.weui-cell__ftelement. - Pattern:
.weui-cells_radio .weui-cell__ft$\rightarrow$.weui-cell__ft_in-radioon the.weui-cell__ftelement.
<!-- Example: Replacing Descendant Selectors -->
<view class="weui-cell weui-cell_access">
<view class="weui-cell__ft weui-cell__ft_in-access"></view>
</view>