lsqy / taro-music

🎉基于taro + taro-ui + redux + react-hooks + typescript 开发的网易云音乐小程序,taro3已升级完毕,目前正在使用react-hooks重构中(不定时更新)
MIT License
1.91k stars 389 forks source link

请教引入font文件的问题。 #110

Closed wangs1203 closed 4 years ago

wangs1203 commented 4 years ago

问题描述 项目中引入font文件 微信开发者工具控制台报错 我自己的项目引入font文件控制台会报错。 但您这个项目本地跑起来并没有报错。 iconfont在真机调试,预览,电脑都正常显示,图标🉑️显示,但微信开发者工具控制台报错

app.tsx

import '@tarojs/async-await';
import Taro, { } from '@tarojs/taro';
import { Provider } from '@tarojs/redux';

import dva from '@utils/dva';
import Index from '@pages/index/index';
import models from '@models/index';

import '@fonts/iconfont/icon.scss';
import '@styles/base.scss';

icon.scss

@font-face {
  font-family: 'FontAwesome';
  src: url('./fontawesome-webfont.eot?v=4.7.0');
  src: url('./fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'), url('./fontawesome-webfont.woff2?v=4.7.0') format('woff2'), url('./fontawesome-webfont.woff?v=4.7.0') format('woff'), url('./fontawesome-webfont.ttf?v=4.7.0') format('truetype'), url('./fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

期望行为 这个错怎么解决。

报错信息 报错如下 VM6183:1 Thu May 14 2020 18:11:41 GMT+0800 (中国标准时间) 渲染层网络层错误 VM5998:1 Failed to load local font resource /pages/searchResult/fontawesome-webfont.woff2?v=4.7.0-do-not-use-local-path-./pages/searchResult/components/SongInfoView/index.wxss&1&102 the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) console.error @ VM5998:1 (anonymous) @ VM6183:2 VM6184:1 Thu May 14 2020 18:11:41 GMT+0800 (中国标准时间) 渲染层网络层错误 VM5998:1 Failed to load local font resource /pages/searchResult/fontawesome-webfont.woff?v=4.7.0-do-not-use-local-path-./pages/searchResult/components/SongInfoView/index.wxss&1&102 net::ERR_CACHE_MISS console.error @ VM5998:1 (anonymous) @ VM6184:2 VM6185:1 Thu May 14 2020 18:11:41 GMT+0800 (中国标准时间) 渲染层网络层错误 VM5998:1 Failed to load local font resource /pages/searchResult/fontawesome-webfont.woff?v=4.7.0-do-not-use-local-path-./pages/searchResult/components/SongInfoView/index.wxss&1&102 the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error) console.error @ VM5998:1 (anonymous) @ VM6185:2 VM6186:1 Thu May 14 2020 18:11:41 GMT+0800 (中国标准时间) 渲染层网络层错误 VM5998:1 Failed to load local font resource /pages/searchResult/fontawesome-webfont.ttf?v=4.7.0-do-not-use-local-path-./pages/searchResult/components/SongInfoView/index.wxss&1&102 net::ERR_CACHE_MISS

console.error @ VM5998:1 (anonymous) @ VM6186:2 VM6187:1 Thu May 14 2020 18:11:41 GMT+0800 (中国标准时间) 渲染层网络层错误 VM5998:1 Failed to load local font resource /pages/searchResult/fontawesome-webfont.ttf?v=4.7.0-do-not-use-local-path-./pages/searchResult/components/SongInfoView/index.wxss&1&102 the server responded with a status of 500 (HTTP/1.1 500 Internal Server Error)

系统信息 👽 Taro v1.3.39

Taro CLI 1.3.39 environment info: System: OS: macOS 10.14.6 Shell: 3.2.57 - /bin/bash Binaries: Node: 12.12.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.4 - /usr/local/bin/npm npmPackages: @tarojs/async-await: 1.3.39 => 1.3.39 @tarojs/components: 1.3.39 => 1.3.39 @tarojs/components-qa: 1.3.39 => 1.3.39 @tarojs/plugin-babel: 1.3.39 => 1.3.39 @tarojs/plugin-csso: 1.3.39 => 1.3.39 @tarojs/plugin-sass: 1.3.39 => 1.3.39 @tarojs/plugin-uglifyjs: 1.3.39 => 1.3.39 @tarojs/redux: 1.3.39 => 1.3.39 @tarojs/redux-h5: 1.3.39 => 1.3.39 @tarojs/router: 1.3.39 => 1.3.39 @tarojs/taro: 1.3.39 => 1.3.39 @tarojs/taro-alipay: 1.3.39 => 1.3.39 @tarojs/taro-h5: 1.3.39 => 1.3.39 @tarojs/taro-qq: 1.3.39 => 1.3.39 @tarojs/taro-quickapp: 1.3.39 => 1.3.39 @tarojs/taro-rn: 1.3.39 => 1.3.39 @tarojs/taro-swan: 1.3.39 => 1.3.39 @tarojs/taro-tt: 1.3.39 => 1.3.39 @tarojs/taro-weapp: 1.3.39 => 1.3.39 @tarojs/webpack-runner: 1.3.39 => 1.3.39 eslint-config-taro: 1.3.39 => 1.3.39 eslint-plugin-taro: 1.3.39 => 1.3.39 nerv-devtools: ^1.5.6 => 1.5.6 nervjs: ^1.5.6 => 1.5.6 stylelint-config-taro-rn: 1.3.39 => 1.3.39 stylelint-taro-rn: 1.3.39 => 1.3.39 npmGlobalPackages: typescript: 3.8.3

lsqy commented 4 years ago

目前已将taro的版本升级到最新版本2.1.5,确保你本地的taro-cli的版本也是这个版本,可以通过taro info查看版本号,如果不是最新的话,可以通过执行taro update self(mac或者linux前面需要加上sudo)以及taro update project进行cli与项目依赖的更新保持一致,否则将会导致项目无法正常运行