国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 灵台县| 新竹县| 汝南县| 溆浦县| 公安县| 辽宁省| 浮梁县| 庆元县| 衡阳市| 土默特左旗| 牡丹江市| 雅江县| 涡阳县| 芒康县| 庆安县| 上饶县| 汤原县| 金山区| 黄骅市| 腾冲县| 济源市| 酒泉市| 汝城县| 河西区| 双牌县| 扎赉特旗| 仙游县| 新绛县| 桂东县| 泰和县| 陆良县| 绥阳县| 隆林| 张家川| 桦川县| 台北县| 临江市| 开平市| 华亭县| 梁平县| 宁强县|