在微信開(kāi)發(fā)工具中運(yùn)行文檔中的代碼,出現(xiàn)如下錯(cuò)誤:
?[渲染層錯(cuò)誤] 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)
出現(xiàn)原因:隨著小程序的發(fā)展,文檔中原來(lái)的寫(xiě)法已經(jīng)不受支持。官方文檔也建議不再使用某些tag而換成新的寫(xiě)法。
解決方法:
第一步,把wxml文件里面要使用wxss的element都賦予一個(gè)類(lèi)名
<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>
?第二步,打開(kāi)相應(yīng)wxss文件,把里面的這種寫(xiě)法“.tab-bar-item?cover-image”改成類(lèi)名““.tab-bar-item-image””
如此這般把所有要用到wxss里面條目的element都改了。文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-518805.html
第三步,把wxml文件中過(guò)時(shí)的“cover-view”和“cover-image”全部改成“view”和“image”。文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-518805.html
到了這里,關(guān)于解決:Some selectors are not allowed in component wxss, including tag name selectors, ID selectors的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!