【南京·10月17日】OSC源創(chuàng)會(huì)開始報(bào)名:Swift、大型移動(dòng)項(xiàng)目構(gòu)架分享 ?
WeUI 是由微信官方設(shè)計(jì)團(tuán)隊(duì)專為微信移動(dòng) Web 應(yīng)用設(shè)計(jì)的 UI 庫。
WeUI 是一套同微信原生視覺體驗(yàn)一致的基礎(chǔ)樣式庫,為微信 Web 開發(fā)量身設(shè)計(jì),可以令用戶的使用感知更加統(tǒng)一。包含button
、cell
、dialog
、toast
、article
、icon
等各式元素。
使用bower
進(jìn)行安裝
使用npm
進(jìn)行安裝
運(yùn)行gulp -ws
命令,會(huì)監(jiān)聽src
目錄下所有文件的變更,并且默認(rèn)會(huì)在8080
端口啟動(dòng)服務(wù)器,然后在瀏覽器打開 http://localhost:8080/example
。
請用微信掃碼
按鈕常見的操作場景:確定、取消、警示,分別對應(yīng)class:weui_btn_primary
、weui_btn_default
、weui_btn_warn
,每種場景都有自己的置灰態(tài)weui_btn_disabled
,除此外還有一種鏤空按鈕weui_btn_plain_xxx
,客戶端webview里的按鈕尺寸有兩類,默認(rèn)寬度100%,小型按鈕寬度自適應(yīng),兩邊邊框與文本間距0.75em:
1 2 3 4 5 6 7 8 9 10 11 12 13 | < a href = "javascript:;" class = "weui_btn weui_btn_primary" >按鈕</ a > < a href = "javascript:;" class = "weui_btn weui_btn_disabled weui_btn_primary" >按鈕</ a > < a href = "javascript:;" class = "weui_btn weui_btn_warn" >確認(rèn)</ a > < a href = "javascript:;" class = "weui_btn weui_btn_disabled weui_btn_warn" >確認(rèn)</ a > < a href = "javascript:;" class = "weui_btn weui_btn_default" >按鈕</ a > < a href = "javascript:;" class = "weui_btn weui_btn_disabled weui_btn_default" >按鈕</ a > < div class = "button_sp_area" > < a href = "javascript:;" class = "weui_btn weui_btn_plain_default" >按鈕</ a > < a href = "javascript:;" class = "weui_btn weui_btn_plain_primary" >按鈕</ a > < a href = "javascript:;" class = "weui_btn weui_btn_mini weui_btn_primary" >按鈕</ a > < a href = "javascript:;" class = "weui_btn weui_btn_mini weui_btn_default" >按鈕</ a > </ div > |
Cell
,列表視圖,用于將信息以列表的結(jié)構(gòu)顯示在頁面上,是wap上最常用的內(nèi)容結(jié)構(gòu)。Cell
由多個(gè)section組成,每個(gè)section包括section headerweui_cells_title
以及cellsweui_cells
。
cell
由thumnailweui_cell_hd
、bodyweui_cell_bd
、accessoryweui_cell_ft
三部分組成,cell
采用自適應(yīng)布局,在需要自適應(yīng)的部分加上classweui_cell_primary
即可:
帶說明的列表項(xiàng)
Cell
可根據(jù)需要進(jìn)行各種自定義擴(kuò)展,包括輔助說明、跳轉(zhuǎn)、單選、復(fù)選等。下面以帶圖標(biāo)、說明、跳轉(zhuǎn)的列表項(xiàng),其他情況可以直接參考example
下的代碼:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | < div class = "weui_cells_title" >帶圖標(biāo)、說明、跳轉(zhuǎn)的列表項(xiàng)</ div > < div class = "weui_cells weui_cells_access" > < a class = "weui_cell" href = "javascript:;" > < div class = "weui_cell_hd" > < img src = "" alt = "icon" style = "width:20px;margin-right:5px;display:block" > </ div > < div class = "weui_cell_bd weui_cell_primary" > < p >cell standard</ p > </ div > < div class = "weui_cell_ft" > 說明文字 </ div > </ a > < a class = "weui_cell" href = "javascript:;" > < div class = "weui_cell_hd" > < img src = "" alt = "icon" style = "width:20px;margin-right:5px;display:block" > </ div > < div class = "weui_cell_bd weui_cell_primary" > < p >cell standard</ p > </ div > < div class = "weui_cell_ft" > 說明文字 </ div > </ a > </ div > |
若系統(tǒng)的alert窗體無法滿足網(wǎng)頁的臨時(shí)視圖內(nèi)容需求,則可以自定義實(shí)現(xiàn)與alert形式相似的dialog,并且在dialog中可以自定義地使用各種控件,來滿足需求。
1 2 3 4 5 6 7 8 9 10 11 | < div class = "weui_dialog_confirm" > < div class = "weui_mask" ></ div > < div class = "weui_dialog" > < div class = "weui_dialog_hd" >< strong class = "weui_dialog_title" >彈窗標(biāo)題</ strong ></ div > < div class = "weui_dialog_bd" >自定義彈窗內(nèi)容< br >...</ div > < div class = "weui_dialog_ft" > < a href = "javascript:;" class = "weui_btn_dialog default" >取消</ a > < a href = "javascript:;" class = "weui_btn_dialog primary" >確定</ a > </ div > </ div > </ div > |
1 2 3 4 5 6 7 8 9 10 | < div class = "weui_dialog_alert" > < div class = "weui_mask" ></ div > < div class = "weui_dialog" > < div class = "weui_dialog_hd" >< strong class = "weui_dialog_title" >彈窗標(biāo)題</ strong ></ div > < div class = "weui_dialog_bd" >彈窗內(nèi)容,告知當(dāng)前頁面信息等</ div > < div class = "weui_dialog_ft" > < a href = "javascript:;" class = "weui_btn_dialog primary" >確定</ a > </ div > </ div > </ div > |
toast用于臨時(shí)顯示某些信息,并且會(huì)在數(shù)秒后自動(dòng)消失。這些信息通常是輕量級操作的成功、失敗或等待狀態(tài)信息。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | < div id = "loadingToast" class = "weui_loading_toast" style = "display:none;" > < div class = "weui_mask_transparent" ></ div > < div class = "weui_toast" > < div class = "weui_loading" > <!-- :) --> < div class = "weui_loading_leaf weui_loading_leaf_0" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_1" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_2" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_3" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_4" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_5" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_6" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_7" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_8" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_9" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_10" ></ div > < div class = "weui_loading_leaf weui_loading_leaf_11" ></ div > </ div > < p class = "weui_toast_content" >數(shù)據(jù)加載中</ p > </ div > </ div > |
結(jié)果頁通常來說可以認(rèn)為進(jìn)行一系列操作步驟后,作為流程結(jié)束的總結(jié)性頁面。結(jié)果頁的作用主要是告知用戶操作處理結(jié)果以及必要的相關(guān)細(xì)節(jié)(可用于確認(rèn)之前的操作是否有誤)等信息;若該流程用于開啟或關(guān)閉某些重要功能,可在結(jié)果頁增加與該功能相關(guān)的描述性內(nèi)容;除此之外,結(jié)果頁也可以承載一些附加價(jià)值操作,例如提供抽獎(jiǎng)、關(guān)注公眾號(hào)等功能入口。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | < div class = "weui_msg" > < div class = "weui_icon_area" >< i class = "weui_icon_success weui_icon_msg" ></ i ></ div > < div class = "weui_text_area" > < h2 class = "weui_msg_title" >操作成功</ h2 > < p class = "weui_msg_desc" >內(nèi)容詳情,可根據(jù)實(shí)際需要安排</ p > </ div > < div class = "weui_opr_area" > < p class = "weui_btn_area" > < a href = "javascript:;" class = "weui_btn weui_btn_primary" >確定</ a > < a href = "javascript:;" class = "weui_btn weui_btn_default" >取消</ a > </ p > </ div > < div class = "weui_extra_area" > < a href = "" >查看詳情</ a > </ div > </ div > |
文字視圖顯示大段文字,這些文字通常是頁面上的主體內(nèi)容。Article
支持分段、多層標(biāo)題、引用、內(nèi)嵌圖片、有/無序列表等富文本樣式,并可響應(yīng)用戶的選擇操作。
在微信客戶端webview中使用Article
,必須保證文字有足夠的可讀性和可辨識(shí)性、使用規(guī)范字體、保證足夠的段間距、段首無縮進(jìn)。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | < article class = "weui_article" > < h1 >大標(biāo)題</ h1 > < section > < h2 class = "title" >章標(biāo)題</ h2 > < section > < h3 >1.1 節(jié)標(biāo)題</ h3 > < p >Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute</ p > </ section > < section > < h3 >1.2 節(jié)標(biāo)題</ h3 > < p >Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</ p > </ section > </ section > </ article > |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | < i class = "weui_icon_msg weui_icon_success" ></ i > < i class = "weui_icon_msg weui_icon_info" ></ i > < i class = "weui_icon_msg weui_icon_warn" ></ i > < i class = "weui_icon_msg weui_icon_waiting" ></ i > < i class = "weui_icon_safe weui_icon_safe_success" ></ i > < i class = "weui_icon_safe weui_icon_safe_warn" ></ i > < div class = "icon_sp_area" > < i class = "weui_icon_success" ></ i > < i class = "weui_icon_success_circle" ></ i > < i class = "weui_icon_success_no_circle" ></ i > < i class = "weui_icon_info" ></ i > < i class = "weui_icon_waiting" ></ i > < i class = "weui_icon_waiting_circle" ></ i > < i class = "weui_icon_circle" ></ i > < i class = "weui_icon_warn" ></ i > < i class = "weui_icon_download" ></ i > </ div > https://github.com/weui/weui |
聯(lián)系客服