简体   繁体   English

使用node.js服务器时如何加载超赞的字体

[英]How to load in font awesome when using node.js server

I am using node server as a test enviroment for a chat application I'm building. 我正在使用节点服务器作为我正在构建的聊天应用程序的测试环境。 I can't seem to load in the font awesome library. 我似乎无法加载真棒字体库。

To link to the css I use this on the server.js: app.use(express.static(path.join(__dirname, 'public'))); 要链接到CSS,我在server.js上使用它:app.use(express.static(path.join(__ dirname,'public')));

And that works. 那行得通。

But it doesn't work for font awesome. 但是它不适用于超棒的字体。

Any suggestions? 有什么建议么?

I would verify that your font-awesome.css and /font folder is updated and no plugins are loading an older version. 我会验证您的font-awesome.css/font文件夹已更新,并且没有插件正在加载旧版本。 Could also be your MIME types are misconfigured. 也可能是您的MIME类型配置错误。 This page may also be of use to you: https://www.paulirish.com/2010/the-protocol-relative-url/ 该页面也可能对您有用: https : //www.paulirish.com/2010/the-protocol-relative-url/

Try to do like this way .. 尝试这样子..

1.make sure you kept your font awesome folder inside /public folder. 1.确保将字体真棒文件夹保存在/ public文件夹中。

2.Next static path to the public folder, also you can try this way without using path.join 公用文件夹 2.Next静态路径,也可以试试这个方法,而无需使用path.join

3.then you can access directly font awesome folder in frond end where you want to use font awesome resources. 3.然后,您可以直接在想要使用字体真棒资源的前端访问字体真棒文件夹。

Check this Image 检查这张图片

There is another way , You can install Bower packaged component can be made up of any type of assets like bootsrap, angular, font awesome and etc. 还有另一种方法,您可以安装Bower打包的组件,该组件可以由任何类型的资产组成,例如bootsrap,angular,font awesome等。

https://www.npmjs.com/package/bower https://www.npmjs.com/package/bower

hope this answer will help for you. 希望这个答案对您有帮助。 sorry If my English is not clear. 对不起,如果我的英语不清楚。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM