国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 開發(fā) > JS > 正文

electron中使用bootstrap的示例代碼

2024-05-06 16:46:44
字體:
供稿:網(wǎng)友

安裝

安裝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="external nofollow" 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" rel="external nofollow" >

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

補充:在electron中使用bootstrap時,雖然在引用bootstrap之前引用了jQuery,但是依然出現(xiàn)錯誤:

Uncaught error: bootstrap's javascript requires jquery

解決方法:不使用script標簽加載jQuery,而是使用下面的方法加載:

window.$ = window.jQuery = require('/path/to/jquery');

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持VeVb武林網(wǎng)。


注:相關教程知識閱讀請移步到JavaScript/Ajax教程頻道。
發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 柞水县| 高陵县| 张家川| 沾化县| 雷州市| 原阳县| 邯郸县| 平塘县| 南安市| 施秉县| 高邮市| 蓬莱市| 沾化县| 黑河市| 偃师市| 克山县| 宁河县| 章丘市| 伊金霍洛旗| 惠来县| 安远县| 黑山县| 班玛县| 新宁县| 阿坝| 厦门市| 吉林省| 蓬莱市| 丰镇市| 修水县| 宜城市| 富宁县| 顺义区| 米林县| 九台市| 麻城市| 揭东县| 呼玛县| 乌兰浩特市| 门源| 板桥市|