uniapp使用字體圖標iconfont報錯原因及解決方式


報錯提示:

MiniProgramError
TypeError: Cannot read property 'getElementsByTagName' of undefined
TypeError: Cannot read property 'getElementsByTagName' of undefined
at at (app-service.js:3900:4153)
at at (app-service.js:3900:5327)
at require (WASubContext.js:2:2405363)
at at (app-service.js:3901:10)

 

原因:

1、因為資源文件放在了static的文件夾目錄下,發布時這寫資源文件被忽略上傳了。

 

解決方式:

1、在static同級目錄下新建一個iconfont的文件夾,把資源文件放到這個文件夾下

2、在App.vue 的style下引入文件的方式要用@,如:@import '@/iconfont/iconfont.css';

 


免責聲明!

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



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