溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務(wù)條款》

electron中使用bootstrap

發(fā)布時間:2020-07-19 22:21:42 來源:網(wǎng)絡(luò) 閱讀:909 作者:tywali 欄目:web開發(fā)

安裝

安裝bootstrap命令如下:
npm install bootstrap --save
 

安裝后可能報告如下錯誤:
npm WARN bootstrap@4.1.3 requires a peer of popper.js@^1.14.3 but none is installed. You must install peer dependencies yourself.
 

需要自行安裝popper,命令如下:
npm install popper.js@^1.14.3 --save
 

頁面引入bootstrap

頁面引入bootstrap的css和js文件如下:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <link href="./node_modules/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet"/>
</head>
<body>
Hello electron!
<div>
    <button id="openFile" class="btn btn-success">Open File</button>
    <button id="sendMsg" class="btn btn-warning">Send Message (Open File)</button>
</div>
<script>
    window.$ = window.jQuery = require('./node_modules/jquery/dist/jquery.min.js');
    require('./node_modules/bootstrap/dist/js/bootstrap.min.js');
</script>

注:網(wǎng)上有的例子中,引入bootstrap.min.css是用傳統(tǒng)方式引入,即:

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

這種方式太搞笑了吧,明明已經(jīng)在本地裝好了全套的bootstrap,偏偏CSS還要用網(wǎng)絡(luò)方式引入,又浪費流量,速度又慢,真是不知道想出這種方式的人是怎么想的。

向AI問一下細節(jié)

免責聲明:本站發(fā)布的內(nèi)容(圖片、視頻和文字)以原創(chuàng)、轉(zhuǎn)載和分享為主,文章觀點不代表本網(wǎng)站立場,如果涉及侵權(quán)請聯(lián)系站長郵箱:is@yisu.com進行舉報,并提供相關(guān)證據(jù),一經(jīng)查實,將立刻刪除涉嫌侵權(quán)內(nèi)容。

AI