解决:Some selectors are not allowed in component wxss, including tag name selectors, ID selectors

在微信开发工具中运行文档中的代码,出现如下错误:

 [渲染层错误] Some selectors are not allowed in component wxss, including tag name selectors, ID selectors, and attribute selectors.(./custom-tab-bar/index.wxss:36:15)(env: Windows,mp,1.06.2210310; lib: 2.5.0)

出现原因:随着小程序的发展,文档中原来的写法已经不受支持。官方文档也建议不再使用某些tag而换成新的写法。

解决方法:

第一步,把wxml文件里面要使用wxss的element都赋予一个类名

<cover-image src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>

改成

<cover-image class="tab-bar-item-image" src="{{selected === index ? item.selectedIconPath : item.iconPath}}"></cover-image>

 第二步,打开相应wxss文件,把里面的这种写法“.tab-bar-item cover-image”改成类名““.tab-bar-item-image””

如此这般把所有要用到wxss里面条目的element都改了。

第三步,把wxml文件中过时的“cover-view”和“cover-image”全部改成“view”和“image”。

  • 5
    点赞
  • 9
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值