最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

electron中使用bootstrap的示例代碼

 更新時間:2018年11月06日 14:10:37   作者:tywali  
這篇文章主要介紹了electron中使用bootstrap的示例代碼,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

安裝

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

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

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

Uncaught error: bootstrap's javascript requires jquery

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

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

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論

攀枝花市| 青浦区| 蒲城县| 吉林市| 淮阳县| 澎湖县| 长治市| 施甸县| 五大连池市| 洛川县| 自贡市| 汾阳市| 姜堰市| 宿迁市| 广饶县| 临湘市| 黎川县| 都江堰市| 河北省| 廊坊市| 和田市| 乌恰县| 东丰县| 顺义区| 故城县| 四川省| 永州市| 孟村| 巴塘县| 资中县| 嘉善县| 芷江| 永平县| 邳州市| 滕州市| 古浪县| 潮州市| 康乐县| 叶城县| 博客| 洪湖市|