小程序真机上报错 for developer: some selectors are not allowed in component wxss , including tag name selectors, id selectors, and attribute selectors

2023-05-25,,

for developer: some selectors are not allowed in component wxss , including tag name selectors, id selectors, and attribute selectors

使用uni-app编译后报以上错误

出现情况:组件中的不可使用button,text,image等标签设置样式
处理:修改成class样式

.avatar image {
width:50upx;
height:50upx;
}
组件和引用组件的页面不能使用id选择器(#a)、属性选择器([a])和标签名选择器,请改用class选择器。
组件和引用组件的页面中使用后代选择器(.a .b)在一些极端情况下会有非预期的表现,如遇,请避免使用。
子元素选择器(.a>.b)只能用于 view 组件与其子节点之间,用于其他组件可能导致非预期的情况。
继承样式,如 font 、 color ,会从组件外继承到组件内。
除继承样式外, app.wxss 中的样式、组件所在页面的的样式对自定义组件无效(除非更改组件样式隔离选项)。

  

参考:https://www.jianshu.com/p/02cad677c36b

程序机上报错 for developer: some selectors are not allowed in component wxss , including tag name selectors, id selectors, and attribute selectors的相关教程结束。

《小程序真机上报错 for developer: some selectors are not allowed in component wxss , including tag name selectors, id selectors, and attribute selectors.doc》

下载本文的Word格式文档,以方便收藏与打印。