[英]Injecting dependencies in <head> vs package.json
I have bootstrap dependency inside the "head" tag of html file which references physically added library files that i downloaded.我在 html 文件的“head”标签内有引导依赖项,该文件引用了我下载的物理添加的库文件。
I also have a bootstrap dependency inside package.json added via npm.我还通过 npm 添加了 package.json 内部的引导依赖项。
I only need the dependencies in one place right?我只需要一个地方的依赖项对吗? For example i can remove from "head" tag and keep inside package.json?
例如,我可以从“head”标签中删除并保留在 package.json 内?
Adding dependencies inside your package.json
does not means that dependencies are automatically used by your bundle: you have to import stuff inside your JS/SASS
to make this happen.在
package.json
中添加依赖项并不意味着包会自动使用依赖项:您必须在JS/SASS
中导入内容才能实现这一点。
You didn't said what is you bootstrap dependency, but let say is the default Bootstrap package.你没有说你的引导依赖是什么,但可以说是默认的引导 package。 You have to do:
你所要做的:
import "bootstrap/dist/css/bootstrap.css"
To have the Bootstrap CSS bundled in your application.将 Bootstrap CSS 捆绑到您的应用程序中。 The same for the JavaScript source... but I don't think you really want to have Bootstrap JS in a React app.
JavaScript 源代码也是如此……但我认为您真的不想在 React 应用程序中使用 Bootstrap JS。 Look at react-bootstrap instead.
请查看react-bootstrap 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.