ldlood同學(xué)推薦 element ui(餓了么基于vue出品)也不錯, github地址:https://github.com/ElemeFE/element. 大家也可以關(guān)注一下
我是一個剛剛接觸前端開發(fā)的新手,所以有必要記錄如何將Bootstrap和Vue進行整合。 如果你是老手,請直接繞道而過。作為一個新手,里面的步驟,過程或者專業(yè)術(shù)語未必正確,如果你發(fā)現(xiàn)哪里錯誤了,請發(fā)郵件至ztao8607@gmail.com
Vue官方不建議新手直接使用vue-cli,但我不這么看。 先使用cli跳過繁瑣的環(huán)境配置,直接看到demo效果能增強點自信心。如果上手就被一大堆的環(huán)境配置搞亂了心情,那才是得不償失呢。 恩. 至少我是這么認為的。
使用vue-cli
如果是使用國內(nèi)網(wǎng)絡(luò)安裝,官方建議使用淘寶或者cnpmjs的鏡像。我感覺淘寶的鏡像速度不如cnpmjs的快,因為我使用的cnpmjs鏡像。
npm --registry http://r.cnpmjs.org install --global vue-cli //安裝vue-clivue init webpack <project name> //創(chuàng)建項目,一般情況使用默認配置就可以cd <project name>npm --registry http://r.cnpmjs.org install //安裝packagenpm run dev
正常的話,你應(yīng)該能看到一個vue的初始化頁面。
整合bootstrap
你可以選擇下載bootstrap zip包,然后將包里面的內(nèi)容放到工程的static目錄中。也可以選擇使用bootstrap cdn資源,我建議使用cdn資源。
1.修改index.html頁面
<!DOCTYPE html><html><head> <meta charset="utf-8"> <title>testproject</title> <!-- 將bootstrap cdn url放到這里 --> <link rel="stylesheet" rel="external nofollow" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> <link rel="stylesheet" rel="external nofollow" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"></head><body> <div id="app"></div> <!-- built files will be auto injected --></body></html>
你可以訪問bootstrap官方網(wǎng)站獲取到最新的cdn資源地址。
2.創(chuàng)建布局
我們創(chuàng)建一個使用bootstrap 柵格布局的例子。 在src/components目錄中創(chuàng)建一個Root.vue文件。在Root.vue文件中,我們先編輯template,創(chuàng)建一個container,然后放入一些導(dǎo)航欄。
里面布局代碼來自于bootstrap官方提供的demo
<template> <div id="root"> <div class="container"> <div class="masthead"> <h3 class="text-muted">Look for it!</h3> <nav> <ul class="nav nav-justified"> <li class="active"><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Home</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Projects</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Services</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Downloads</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >About</a></li> <li><a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" >Contact</a></li> </ul> </nav> </div> </div> <mfooter></mfooter> </div></template>
新聞熱點
疑難解答
圖片精選