[英]I want to use bootstrap's cdn in my react project. Where and how do I insert the cdn?
我目前正在開發一個 React 單頁應用程序,我無法弄清楚在我的項目中放置Bootstrap
CDN
位置和方式以使我的引導程序正常工作。
此外,如果有人可以建議如何為您的項目npm
install bootstrap。
如果您使用 create-react-app,則 public/index.html 中有一個文件,或者讓我們說在您的 index html 頁面中,您首先在那里使用 cdn 呈現
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="theme-color" content="#000000">
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/latest/css/bootstrap.min.css">
<title>React App</title>
</head>
CDN
<HTML>
<head>
<!-- YOU CDN -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
</head>
<body></body>
</HTML>
新產品經理
npm install bootstrap@3
require('bootstrap') 會將所有 Bootstrap 的 jQuery 插件加載到 jQuery 對象上。 bootstrap 模塊本身不導出任何內容。 您可以通過加載包頂級目錄下的 /js/*.js 文件來單獨手動加載 Bootstrap 的 jQuery 插件。
Bootstrap 的 package.json 在以下鍵下包含一些額外的元數據:
less - Bootstrap 的主要 Less 源文件樣式的路徑 - Bootstrap 的非縮小 CSS 的路徑,該 CSS 已使用默認設置進行預編譯(無自定義)
npm install --save bootstrap
在 App.js 中導入這個之后
import 'bootstrap/dist/css/bootstrap.min.css';
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.