如何在reactjs中从cdn导入库? [英] how to import libraries from cdn in reactjs?

查看:45
本文介绍了如何在reactjs中从cdn导入库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试过了:

import 'maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css';

但它会产生错误.如何在我的 app.js 文件中导入 CDN?

but it produces error. How can i import a cdn in my app.js file?

推荐答案

你没有在你的 JS 中捆绑 CDN 的东西,这违背了将它放在 CDN 上的目的:).如果这是 JS,我会要求你使用 externals,但是对于 CSS,你可以使用 https://github.com/jso0/html-webpack-cdn-plugin 代替.

You don't bundle CDN stuff inside your JS, that sort of defeats the purpose of having it on CDN :). Had this been JS, I would have asked you to use externals, but for a CSS, you can use https://github.com/jso0/html-webpack-cdn-plugin instead.

这篇关于如何在reactjs中从cdn导入库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆