W3Cschool
恭喜您成為首批注冊用戶
獲得88經驗值獎勵
解釋: 關注組件,內容/用戶關注組件。開發(fā)者可在小程序內配置關注組件,實現(xiàn)用戶對內容和用戶的關注,可嵌套在原生組件內,自定義選擇組件的樣式和動效。
屬性名 | 類型 | 必填 | 默認值 | 說明 |
---|---|---|---|---|
mode | String | 否 | text | 關注按鈕模式,有三種選擇。 icon :僅有圖標; text :文字版本; mixture :圖標文字結合。 |
background-color | String | 否 | blue | mode 為 mixture 時不支持自定義背景色,默認背景為藍色;當且僅當 mode 為 text 時有以下 4 種按鈕顏色可選 blue 、 white 、 opacity 、 none 。當且僅當 mode 為 icon 時有以下 2 種按鈕顏色可選 blue 、 white 。 |
is-followed | Boolean | 是 | false | 關注的狀態(tài) |
follow-text | Array | 否 | ['關注', '已關注'] | 關注按鈕上的文案 |
is-show-toast | Boolean | 否 | true | 關注后的結果反饋是否彈出 toast 提示 |
toast-text | Array | 否 | ['關注成功', '已取消關注'] | toast 文案,默認為關注成功、已取消關注。 |
bind:follow | EventHandle | 點擊按鈕事件 |
安裝組件:
<view>關注</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: ['關注', '取消關注'],
followText2: ['關注', '已經取消關注']
},
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": "標題",
"usingComponents": {
"c-follow": "@smt-ui/content-component/src/follow"
}
}
Copyright©2021 w3cschool編程獅|閩ICP備15016281號-3|閩公網安備35020302033924號
違法和不良信息舉報電話:173-0602-2364|舉報郵箱:jubao@eeedong.com
掃描二維碼
下載編程獅App
編程獅公眾號
聯(lián)系方式:
更多建議: