iT邦幫忙

0

Angular Step by Step - 安裝Bootstrap

WM 2020-04-12 15:30:28906 瀏覽
  • 分享至 

  • xImage
  •  

這次要練習的Angular結構圖:
https://ithelp.ithome.com.tw/upload/images/20200412/20112573aUCN54jopo.png

node與Angular版本:
https://ithelp.ithome.com.tw/upload/images/20200412/20112573Pr6xN2qJjV.png

建置完專案後,首先要安裝bootstrap。
在命令提示字元輸入指令npm i bootstrap
安裝完成後,可以在node_modules/bootstrap/dist/css/bootstrap.min.css找到我們需要的css檔:
https://ithelp.ithome.com.tw/upload/images/20200412/20112573EsMdxo0vZV.png

angular.json中,將bootstrap的路徑加到styles[]
https://ithelp.ithome.com.tw/upload/images/20200412/201125735JidgEvi8M.png

直接將app.component.html內容改成:

<div class="alert alert-primary" role="alert">
  A simple primary alert—check it out!
</div>
<div class="alert alert-secondary" role="alert">
  A simple secondary alert—check it out!
</div>
<div class="alert alert-success" role="alert">
  A simple success alert—check it out!
</div>
<div class="alert alert-danger" role="alert">
  A simple danger alert—check it out!
</div>
<div class="alert alert-warning" role="alert">
  A simple warning alert—check it out!
</div>
<div class="alert alert-info" role="alert">
  A simple info alert—check it out!
</div>
<div class="alert alert-light" role="alert">
  A simple light alert—check it out!
</div>
<div class="alert alert-dark" role="alert">
  A simple dark alert—check it out!
</div>

測試是否成功:
https://ithelp.ithome.com.tw/upload/images/20200412/20112573fBrKSlNE9m.png

參考來源:
Angular - The Complete Guide (2020 Edition)


圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言