小程序真機上報錯 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

 

使用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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM