国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

xmlplus組件設(shè)計(jì)系列之按鈕(2)

2024-05-06 15:17:57
字體:
供稿:網(wǎng)友

除了圖標(biāo)以外,按鈕也許是最簡單的組件了,現(xiàn)在來看看如何定義按鈕組件。

使用原生按鈕組件

在 xmlplus 中,HTML 元素也以組件的方式存在。所以,你可以直接通過使用 button 標(biāo)簽或者 input 標(biāo)簽來使用按鈕組件。如下示例所示:

Example: {  xml: "<div id='example'>/       <button>Default</button>/       <input type='submit'>Primary</input>/     </div>"}

雖然原生按鈕外觀不那么吸引人,但原生按鈕未經(jīng)特殊包裝,所以渲染起來最快,執(zhí)行效率最高。

使用 Bootstrap 樣式的按鈕

如果你的項(xiàng)目在視覺上沒有特別要求的話。使用 Bootstrap 樣式來定義按鈕組件是一個(gè)好主意。按傳統(tǒng)方式使用 Bootstrap 按扭,你需要像下面這樣使用。

<button type="button" class="btn btn-default">Default</button><button type="button" class="btn btn-primary">Primary</button><button type="button" class="btn btn-success">Success</button>

請(qǐng)認(rèn)真觀察,你是不是覺得它給你的比你要求的要多。你不但發(fā)現(xiàn)了好多的 type=button,還發(fā)現(xiàn)了好多的 btn。現(xiàn)在下面給出一個(gè)組件,它基于 Bootstrap 樣式,但它明顯地簡化了按鈕的使用方式。

Button: {  xml: "<button type='button' class='btn'/>",  fun: function (sys, items, opts) {    this.addClass("btn-" + opts.type);  }}

此按鈕組件封裝了原始按鈕需要重復(fù)書寫的內(nèi)容,在使用時(shí),僅需提供 type 屬性即可指明目標(biāo)按鈕,使用起來更為便捷。下面給出的是新按鈕組件的使用方式。

<Button type='default'>Default</Button><Button type='primary'>Primary</Button><Button type='success'>Success</Button>

帶有圖標(biāo)的按鈕

按鈕上除了文字外,還可以附帶圖標(biāo)。合適的圖標(biāo)可以使按扭的使用意圖更加生動(dòng)直觀。這里以 EasyUI 的圖標(biāo)按鈕為例來說明如何封裝并使用圖標(biāo)按鈕。我們首先來看看,EasyUI 圖標(biāo)按鈕的原始使用方式。

<div style="padding:5px 0;">  <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" data-options="iconCls:'icon-add'">Add</a>  <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" data-options="iconCls:'icon-remove'">Remove</a>  <a href="#" rel="external nofollow" rel="external nofollow" rel="external nofollow" rel="external nofollow" class="easyui-linkbutton" data-options="iconCls:'icon-save'">Save</a></div>

與上一節(jié)對(duì) Bootstrap 按鈕的封裝類似,通過觀察提煉出重復(fù)出現(xiàn)的部分,將變化的部分以接口形式展現(xiàn)。上面的按鈕僅圖標(biāo)類型名和文本是可變的,所以我們可以做出如下的設(shè)計(jì):

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表

圖片精選

主站蜘蛛池模板: 寿宁县| 林州市| 陈巴尔虎旗| 丰台区| 昔阳县| 嘉鱼县| 锡林浩特市| 龙海市| 乌恰县| 乌审旗| 收藏| 大足县| 宕昌县| 吉木萨尔县| 无极县| 涟源市| 通河县| 荃湾区| 海南省| 绥化市| 石河子市| 丽水市| 贵港市| 白山市| 南华县| 城步| 兴文县| 灵宝市| 泰兴市| 吴川市| 孟津县| 唐山市| 平原县| 威远县| 盐边县| 盐边县| 新河县| 新河县| 乌拉特中旗| 荣昌县| 鹰潭市|