W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
基礎(chǔ)庫(kù) 1.0.0 開始支持,低版本需做兼容處理。
按鈕。
屬性 | 類型 | 默認(rèn)值 | 必填 | 說明 | 最低版本 |
---|---|---|---|---|---|
size | string | default | 否 | 按鈕的大小 | 1.0.0 |
type | string | default | 否 | 按鈕的樣式類型 | 1.0.0 |
plain | boolean | false | 否 | 按鈕是否鏤空,背景色透明 | 1.0.0 |
disabled | boolean | false | 否 | 是否禁用 | 1.0.0 |
loading | boolean | false | 否 | 名稱前是否帶 loading 圖標(biāo) | 1.0.0 |
form-type | string | 否 | 用于 form 組件,點(diǎn)擊分別會(huì)觸發(fā) form 組件的 submit/reset 事件 | 1.0.0 | |
open-type | string | 否 | 微信開放能力 | 1.1.0 | |
hover-class | string | button-hover | 否 | 指定按鈕按下去的樣式類。當(dāng) hover-class="none" 時(shí),沒有點(diǎn)擊態(tài)效果 |
1.0.0 |
hover-stop-propagation | boolean | false | 否 | 指定是否阻止本節(jié)點(diǎn)的祖先節(jié)點(diǎn)出現(xiàn)點(diǎn)擊態(tài) | 1.5.0 |
hover-start-time | number | 20 | 否 | 按住后多久出現(xiàn)點(diǎn)擊態(tài),單位毫秒 | 1.0.0 |
hover-stay-time | number | 70 | 否 | 手指松開后點(diǎn)擊態(tài)保留時(shí)間,單位毫秒 | 1.0.0 |
lang | string | en | 否 | 指定返回用戶信息的語言,zh_CN 簡(jiǎn)體中文,zh_TW 繁體中文,en 英文。 | 1.3.0 |
session-from | string | 否 | 會(huì)話來源,open-type="contact"時(shí)有效 | 1.4.0 | |
send-message-title | string | 當(dāng)前標(biāo)題 | 否 | 會(huì)話內(nèi)消息卡片標(biāo)題,open-type="contact"時(shí)有效 | 1.5.0 |
send-message-path | string | 當(dāng)前分享路徑 | 否 | 會(huì)話內(nèi)消息卡片點(diǎn)擊跳轉(zhuǎn)小程序路徑,open-type="contact"時(shí)有效 | 1.5.0 |
send-message-img | string | 截圖 | 否 | 會(huì)話內(nèi)消息卡片圖片,open-type="contact"時(shí)有效 | 1.5.0 |
app-parameter | string | 否 | 打開 APP 時(shí),向 APP 傳遞的參數(shù),open-type=launchApp時(shí)有效 | 1.9.5 | |
show-message-card | boolean | false | 否 | 是否顯示會(huì)話內(nèi)消息卡片,設(shè)置此參數(shù)為 true,用戶進(jìn)入客服會(huì)話會(huì)在右下角顯示"可能要發(fā)送的小程序"提示,用戶點(diǎn)擊后可以快速發(fā)送小程序消息,open-type="contact"時(shí)有效 | 1.5.0 |
bindgetuserinfo | eventhandle | 否 | 用戶點(diǎn)擊該按鈕時(shí),會(huì)返回獲取到的用戶信息,回調(diào)的detail數(shù)據(jù)與wx.getUserInfo返回的一致,open-type="getUserInfo"時(shí)有效 | 1.3.0 | |
bindcontact | eventhandle | 否 | 客服消息回調(diào),open-type="contact"時(shí)有效 | 1.5.0 | |
bindgetphonenumber | eventhandle | 否 | 獲取用戶手機(jī)號(hào)回調(diào),open-type=getPhoneNumber時(shí)有效 | 1.2.0 | |
binderror | eventhandle | 否 | 當(dāng)使用開放能力時(shí),發(fā)生錯(cuò)誤的回調(diào),open-type=launchApp時(shí)有效 | 1.9.5 | |
bindopensetting | eventhandle | 否 | 在打開授權(quán)設(shè)置頁后回調(diào),open-type=openSetting時(shí)有效 | 2.0.7 | |
bindlaunchapp | eventhandle | 否 | 打開 APP 成功的回調(diào),open-type=launchApp時(shí)有效 | 2.4.4 |
size 的合法值
值 | 說明 | 最低版本 |
---|---|---|
default | 默認(rèn)大小 | |
mini | 小尺寸 |
type 的合法值
值 | 說明 | 最低版本 |
---|---|---|
primary | 綠色 | |
default | 白色 | |
warn | 紅色 |
form-type 的合法值
值 | 說明 | 最低版本 |
---|---|---|
submit | 提交表單 | |
reset | 重置表單 |
open-type 的合法值
值 | 說明 | 最低版本 |
---|---|---|
contact | 打開客服會(huì)話,如果用戶在會(huì)話中點(diǎn)擊消息卡片后返回小程序,可以從 bindcontact 回調(diào)中獲得具體信息,具體說明 | 1.1.0 |
share | 觸發(fā)用戶轉(zhuǎn)發(fā),使用前建議先閱讀使用指引 | 1.2.0 |
getPhoneNumber | 獲取用戶手機(jī)號(hào),可以從bindgetphonenumber回調(diào)中獲取到用戶信息,具體說明 | 1.2.0 |
getUserInfo | 獲取用戶信息,可以從bindgetuserinfo回調(diào)中獲取到用戶信息 | 1.3.0 |
launchApp | 打開APP,可以通過app-parameter屬性設(shè)定向APP傳的參數(shù)具體說明 | 1.9.5 |
openSetting | 打開授權(quán)設(shè)置頁 | 2.0.7 |
feedback | 打開“意見反饋”頁面,用戶可提交反饋內(nèi)容并上傳日志,開發(fā)者可以登錄小程序管理后臺(tái)后進(jìn)入左側(cè)菜單“客服反饋”頁面獲取到反饋內(nèi)容 | 2.1.0 |
lang 的合法值
值 | 說明 | 最低版本 |
---|---|---|
en | 英文 | |
zh_CN | 簡(jiǎn)體中文 | |
zh_TW | 繁體中文 |
/** 修改button默認(rèn)的點(diǎn)擊態(tài)樣式類**/
.button-hover {
background-color: red;
}
/** 添加自定義button點(diǎn)擊態(tài)樣式類**/
.other-button-hover {
background-color: blue;
}
WXML文件
<button type="default" size="{{defaultSize}}" loading="{{loading}}" plain="{{plain}}"
disabled="{{disabled}}" bindtap="default" hover-class="other-button-hover"> default </button>
<button type="primary" size="{{primarySize}}" loading="{{loading}}" plain="{{plain}}"
disabled="{{disabled}}" bindtap="primary"> primary </button>
<button type="warn" size="{{warnSize}}" loading="{{loading}}" plain="{{plain}}"
disabled="{{disabled}}" bindtap="warn"> warn </button>
<button bindtap="setDisabled">點(diǎn)擊設(shè)置以上按鈕disabled屬性</button>
<button bindtap="setPlain">點(diǎn)擊設(shè)置以上按鈕plain屬性</button>
<button bindtap="setLoading">點(diǎn)擊設(shè)置以上按鈕loading屬性</button>
<button open-type="contact">進(jìn)入客服會(huì)話</button>
JS文件
var types = ['default', 'primary', 'warn']
var pageObject = {
data: {
defaultSize: 'default',
primarySize: 'default',
warnSize: 'default',
disabled: false,
plain: false,
loading: false
},
setDisabled: function(e) {
this.setData({
disabled: !this.data.disabled
})
},
setPlain: function(e) {
this.setData({
plain: !this.data.plain
})
},
setLoading: function(e) {
this.setData({
loading: !this.data.loading
})
}
}
for (var i = 0; i < types.length; ++i) {
(function(type) {
pageObject[type] = function(e) {
var key = type + 'Size'
var changedData = {}
changedData[key] =
this.data[key] === 'default' ? 'mini' : 'default'
this.setData(changedData)
}
})(types[i])
}
Page(pageObject)
Copyright©2021 w3cschool編程獅|閩ICP備15016281號(hào)-3|閩公網(wǎng)安備35020302033924號(hào)
違法和不良信息舉報(bào)電話:173-0602-2364|舉報(bào)郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號(hào)
聯(lián)系方式:
更多建議: