W3Cschool
恭喜您成為首批注冊(cè)用戶
獲得88經(jīng)驗(yàn)值獎(jiǎng)勵(lì)
解釋?zhuān)?關(guān)注組件,內(nèi)容/用戶關(guān)注組件。開(kāi)發(fā)者可在小程序內(nèi)配置關(guān)注組件,實(shí)現(xiàn)用戶對(duì)內(nèi)容和用戶的關(guān)注,可嵌套在原生組件內(nèi),自定義選擇組件的樣式和動(dòng)效。
屬性名 | 類(lèi)型 | 必填 | 默認(rèn)值 | 說(shuō)明 |
---|---|---|---|---|
mode | String | 否 | text | 關(guān)注按鈕模式,有三種選擇。 icon :僅有圖標(biāo); text :文字版本; mixture :圖標(biāo)文字結(jié)合。 |
background-color | String | 否 | blue | mode 為 mixture 時(shí)不支持自定義背景色,默認(rèn)背景為藍(lán)色;當(dāng)且僅當(dāng) mode 為 text 時(shí)有以下 4 種按鈕顏色可選 blue 、 white 、 opacity 、 none 。當(dāng)且僅當(dāng) mode 為 icon 時(shí)有以下 2 種按鈕顏色可選 blue 、 white 。 |
is-followed | Boolean | 是 | false | 關(guān)注的狀態(tài) |
follow-text | Array | 否 | ['關(guān)注', '已關(guān)注'] | 關(guān)注按鈕上的文案 |
is-show-toast | Boolean | 否 | true | 關(guān)注后的結(jié)果反饋是否彈出 toast 提示 |
toast-text | Array | 否 | ['關(guān)注成功', '已取消關(guān)注'] | toast 文案,默認(rèn)為關(guān)注成功、已取消關(guān)注。 |
bind:follow | EventHandle | 點(diǎn)擊按鈕事件 |
安裝組件:
<view>關(guān)注</view>
<view class="con-demo">
<c-follow
is-followed="{{isFollowed1}}"
bind:follow="onFollow1">
</c-follow>
<c-follow
background-color="white"
follow-text="{{followText}}"
is-followed="{{isFollowed2}}"
bind:follow="onFollow2">
</c-follow>
<c-follow
background-color="opacity"
follow-text="{{followText2}}"
is-followed="{{isFollowed4}}"
bind:follow="onFollow4">
</c-follow>
<c-follow
background-color="none"
follow-text="{{followText}}"
is-followed="{{isFollowed3}}"
bind:follow="onFollow3">
</c-follow>
</view>
<view class="con-demo">
<c-follow
mode="icon"
background-color="white"
is-followed="{{isFollowed5}}"
bind:follow="onFollow5">
</c-follow>
<c-follow
mode="icon"
is-followed="{{isFollowed6}}"
bind:follow="onFollow6">
</c-follow>
</view>
<view class="con-demo">
<c-follow
mode="mixture"
is-followed="{{isFollowed}}"
bind:follow="onFollow">
</c-follow>
</view>
Page({
data: {
isFollowed: true,
followText: ['關(guān)注', '取消關(guān)注'],
followText2: ['關(guān)注', '已經(jīng)取消關(guān)注']
},
onFollow() {
let isFollowed = this.data.isFollowed;
this.setData('isFollowed', !isFollowed);
},
onFollow1() {
let isFollowed = this.data.isFollowed1;
this.setData('isFollowed1', !isFollowed);
},
onFollow2() {
let isFollowed = this.data.isFollowed2;
this.setData('isFollowed2', !isFollowed);
},
onFollow3() {
let isFollowed = this.data.isFollowed3;
this.setData('isFollowed3', !isFollowed);
},
onFollow4() {
let isFollowed = this.data.isFollowed4;
this.setData('isFollowed4', !isFollowed);
},
onFollow5() {
let isFollowed = this.data.isFollowed5;
this.setData('isFollowed5', !isFollowed);
},
onFollow6() {
let isFollowed = this.data.isFollowed6;
this.setData('isFollowed6', !isFollowed);
}
});
.con-demo {
display: flex;
height: 80px;
align-items: center;
justify-content: space-around;
background: #666;
height: 50px;
}
{
"navigationBarTitleText": "標(biāo)題",
"usingComponents": {
"c-follow": "@smt-ui/content-component/src/follow"
}
}
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)系方式:
更多建議: