小程序文档说目前支持的选择器有:selectorsamplesampledescription.class.intro选择所有class="intro"的组件#id#firstname选择id="firstname"的组件elementview选择所有viewsComponentselement,elementview,checkboxselectalldocumentviewcomponentsandallcheckboxcomponents::afterview::afterinsertcontentafterviewcomponents::beforeview::beforeinsertscontentbeforeviewcomponents在实践中,我发现,除了documents提到的几个选择器,经过测试,它发现居然还有几个支持的选择器没有列出来!还支持哪些选择器?后面讲解的例子都是基于这个xml结构:eldestsonsecondsonthirdsonButton“~”选择器选择同级的所有后续元素:.parenttext{显示:块;font-size:24px;}text.son-1~text{color:#69c;}“+”选择器选择紧随其后的兄弟元素:.parenttext{display:block;font-size:24px;}text.son-1+text{color:#69c;}xx:nth-child(n)第n个xx对应的元素expression.parent>text{display:block;font-size:24px;}.parent>text:nth-child(2){color:#f10;}经过测试,类似于::last-of-type(n),:nth-last-child(n),:nth-last-of-type(n),:first-of-type也很容易使用。[attribute]有attribute属性的元素button[type]{height:200px;}已经测试过了,类似:[attribute=value],[attribute~=value],[attribute|=value]也很好用.注意:由于微信支持的标签上的属性与HTML不一致,所以有很多HTML支持的属性是微信不支持的。如果不受支持的属性是不使用属性选择器。微信支持的标签在本文补充选择器中列出::nth-child(n):last-of-type(n):nth-last-child(n):nth-last-of-type(n):first-of-type[attribute][attribute=value][attribute~=value][attribute|=value]本人也是刚开始学习微信小程序开发,可能有疏漏之处,还请多多包涵我以及更正,如果以后有新的发现,我会补充到本文中,方便大家。感谢您阅读。感谢您在微信群阅读。有问题可以加群。群里有很多有趣的前端小伙伴。让我们一起学习,一起成长!也可以加我微信,我拉你进微信群(由于腾讯限制100人进微信群,超过100人我必须拉你进)