解决:[渲染层错误] 问题

[渲染层错误] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./custom-tab-bar/index.wxss:31:15)

(env: Windows,mp,1.06.2212011; lib: 2.5.0)

经实验,在页面对应的wxss的这两个地方都是有问题的,开发工具只报了最后一个有问题

.tab-bar-item cover-image {
  width: 27px;
  height: 27px;
}

.tab-bar-item cover-view {
    font-size: 10px;
  }
  

原因:因为wxss里面很多写法是不行的,详见:(14条消息) 小程序自定义组件报错:Some selectors are not allowed in component wxss, including tag name selectors..._岁月如歌!的博客-CSDN博客

解决方法:到wxml里面把没有class属性的cover-image、cover-view都赋予class名字,用这个名字来控制样式。即把上面的css代码改成:

.tab-bar-item .ci0 {
  width: 27px;
  height: 27px;
}

.tab-bar-item .cv0 {
    font-size: 10px;
  }

猜你喜欢

转载自blog.csdn.net/K8001/article/details/129063668
今日推荐