1、文件不存在,先檢查一下服務器上 對應的路徑上有沒有對應的文件
2、mime.types的原因 需要加對應的type,如
application/x-font-truetype ttf;
application/x-font-woff woff woff2;(可省略)
3、同源策略的原因,跨域的問題
在nginx.conf 添加如下:
location ~* \.(eot|otf|ttf|woff|svg)$ {
add_header Access-Control-Allow-Origin *;
}
4、nginx識別路徑問題
如果以上都不行,檢查一下日志,如果出現
/etc/nginx/html/my-web/static/fonts/8417dfa4.DIN-Condensed-Bold.ttf" failed (2: No such file or directory):
則檢查一下nginx.conf 下的 location的root 指定(需要保持一致),修改如下
location / {
root /www;
index index.html index.htm;
}
location ~* \.(eot|otf|ttf|woff|svg)$ {
root /www;
add_header Access-Control-Allow-Origin *;
}
