WeUI 为微信 Web 服务量身规划

概述

WeUI是一套同微信原生视觉体会一起的根底款式库,由微信官方规划团队为微信 Web 开发量身规划,能够令用户的运用感知愈加一起。包含buttoncelldialogtoastarticleicon等各式元素。


装置

办法一:

运用bower进行装置

bower install --save weui

办法二:

运用npm进行装置

npm install --save weui

开发

git clone https://github.com/weui/weui.git
cd weui
npm install -g gulp
npm install
gulp -ws

运转gulp -ws指令,会监听src目录下全部文件的改变,而且默许会在8080端口发动服务器,然后在阅读器翻开 http://localhost:8080/example


手机预览

请用微信扫码

WEUI 在线实例


按钮(Button)

按钮能够运用a或许button标签。wap上要触发按钮的active态,有必要触发ontouchstart事情,能够在body上加上ontouchstart=""大局触发。

按钮常见的操作场景:承认、撤销、警示,别离对应class:weui_btn_primaryweui_btn_defaultweui_btn_warn,每种场景都有自己的置灰态weui_btn_disabled,除此外还有一种镂空按钮weui_btn_plain_xxx,客户端webview里的按钮尺度有两类,默许宽度100%,小型按钮宽度自适应,两头边框与文本距离0.75em:

<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">承认</a>
<a href="javascript:;" class="weui_btn weui_btn_disabled weui_btn_warn">承认</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)

Cell,列表视图,用于将信息以列表的结构显现在页面上,是wap上最常用的内容结构。Cell由多个section组成,每个section包含section headerweui_cells_title以及cellsweui_cells

cell由thumbnailweui_cell_hd、bodyweui_cell_bd、accessoryweui_cell_ft三部分组成,cell选用自适应布局,在需求自适应的部分加上classweui_cell_primary即可:

带阐明的列表项

<div class="weui_cells_title">带阐明的列表项</div>
<div class="weui_cells">
    <div class="weui_cell">
        <div class="weui_cell_bd weui_cell_primary">
            <p>标题文字</p>
        </div>
        <div class="weui_cell_ft">
            阐明文字
        </div>
    </div>
</div>

Cell可依据需求进行各种自界说扩展,包含辅佐阐明、跳转、单选、复选等。下面以带图标、阐明、跳转的列表项,其他情况能够直接参阅example下的代码:

<div class="weui_cells_title">带图标、阐明、跳转的列表项</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>

对话框(Dialog)

若体系的alert窗体无法满意网页的暂时视图内容需求,则能够自界说完结与alert方式相似的dialog,而且在dialog中能够自界说地运用各种控件,来满意需求。

<div class="weui_dialog_confirm">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
        <div class="weui_dialog_bd">自界说弹窗内容<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>
<div class="weui_dialog_alert">
    <div class="weui_mask"></div>
    <div class="weui_dialog">
        <div class="weui_dialog_hd"><strong class="weui_dialog_title">弹窗标题</strong></div>
        <div class="weui_dialog_bd">弹窗内容,奉告当时页面信息等</div>
        <div class="weui_dialog_ft">
            <a href="javascript:;" class="weui_btn_dialog primary">承认</a>
        </div>
    </div>
</div>

Toast

toast用于暂时显现某些信息,而且会在数秒后主动消失。这些信息一般是轻量级操作的成功、失利或等候情况信息。

<div id="toast" style="display: none;">
    <div class="weui_mask_transparent"></div>
    <div class="weui_toast">
        <i class="weui_icon_toast"></i>
        <p class="weui_toast_content">已完结</p>
    </div>
</div>
<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">数据加载中</p>
    </div>
</div>

成果页(Msg Page)

成果页一般来说能够以为进行一系列操作进程后,作为流程完毕的总结性页面。成果页的效果首要是奉告用户操作处理成果以及必要的相关细节(可用于承认之前的操作是否有误)等信息;若该流程用于敞开或封闭某些重要功用,可在成果页增加与该功用相关的描绘性内容;除此之外,成果页也能够承载一些附加价值操作,例如供给抽奖、重视大众号等功用进口。

<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">内容概况,可依据实际需求组织</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>

文章页

文字视图显现大段文字,这些文字一般是页面上的主体内容。Article支撑分段、多层标题、引证、内嵌图片、有/无序列表等富文本款式,并可呼运用户的挑选操作。

在微信客户端webview中运用Article,有必要确保文字有满足的可读性和可辨识性、运用标准字体、确保满足的段距离、段首无缩进。

<article class="weui_article">
    <h1>大标题</h1>
    <section>
        <h2 class="title">章标题</h2>
        <section>
            <h3>1.1 节标题</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 节标题</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>

图标

<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>
    <i class="weui_icon_info_circle"></i>
</div>

项目下载地址

Github 地址:

本站地址: