wxc-list
列表组件 - 小程序组件
Install
$ min install @minui/wxc-list
Demos
配置icon
<template>
<view class="list-wrap">
<view class="list-item">
<wxc-list
wx:for="{{list}}"
wx:key="index"
class="item"
title="{{item.title}}"
desc="{{item.slot? '' : item.desc}}"
mode="{{index == list.length-1 ? 'none': ''}}"
src="{{item.src}}">
<view wx:if="{{item.slot && item.desc}}" class="desc-highlight">{{item.desc}}</view>
</wxc-list>
</view>
<view class="list-item">
<wxc-list
class="item"
icon="help"
icon-color="#69A0DD"
title="客服与帮助"></wxc-list>
<wxc-list
class="item"
icon="feedback"
icon-color="#69A0DD"
mode="none"
title="意见反馈"></wxc-list>
</view>
</view>
</template>
<script>
export default {
config: {
usingComponents: {
'wxc-list': '@minui/wxc-list',
'wxc-icon': '@minui/wxc-icon'
}
},
data: {
list: [{
title: '打卡领红包',
desc: '您有1个10元红包可领取',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/171226_2kall2je2079dh6ddkgc31d27cce2_38x38.png'
}, {
title: '优惠券',
desc: '满100减20',
slot: true,
src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_7ida8bdc21j18b91aa2ii3lk38b9i_38x38.png'
}, {
title: '钱和红包',
desc: '',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/171011_0acg74g776ig2459c1c6gkge07hch_40x40.png'
}, {
title: '我的消息',
desc: '和卖家沟通在这里',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_0ea73id6h6926k281cdhia0dg5gdg_38x38.png'
}, {
title: '我的收藏',
desc: '',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_6h37fg4074i3a2l2gb92dbbc15k84_38x38.png'
}, {
title: '足迹',
desc: '',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_00di1ei7f095j8b996icg79kl91kc_38x38.png'
}, {
title: '我的拼团',
desc: '',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/170603_55gkg003el4k2jbg2d2ieh030fjcf_38x38.png'
}, {
title: '充值中心',
desc: '',
slot: false,
src: 'https://s10.mogucdn.com/mlcdn/c45406/180109_26hggaiha8k7blig5k4ihk5k967ii_38x38.png'
}]
},
methods: { }
}
</script>
<style>
.list-wrap {
width: 100%;
background: #efefef;
padding-bottom: 30rpx;
padding-top: 30rpx;
}
.list-item {
background: #fff;
margin-bottom: 30rpx;
}
.list-item:last-child {
margin: 0;
}
.item {
flex: 1;
}
.desc-highlight {
font-size: 24rpx;
height: 38rpx;
padding: 0 22rpx;
border: 1px solid #f5342f;
border-radius: 20rpx;
color: #f5342f;
line-height: 38rpx;
}
</style>
基础用法
<template>
<view class="list-wrap">
<view class="list-item">
<wxc-list title="标题文字" desc="内容描述" mode="none"></wxc-list>
<wxc-list title="标题文字" desc="内容描述" dot="{{true}}"></wxc-list>
<wxc-list title="标题文字" desc="内容描述" arrow="{{false}}"></wxc-list>
<wxc-list title="标题文字" arrow="{{false}}" mode="none">
<switch type="switch" color="#ff5777"></switch>
</wxc-list>
</view>
<view class="list-item">
<view class="list-check">
<view class="check-wrap"></view>
<wxc-list class="item" title="标题文字" desc="内容描述"></wxc-list>
</view>
<view class="list-check">
<view class="check-wrap" bindtap="onCheck">
<wxc-icon wx:if="{{check}}" class="check" type="check" size="46" color="#ff5777"></wxc-icon>
</view>
<wxc-list class="item" title="标题文字" desc="内容描述" mode="none"></wxc-list>
</view>
</view>
<view class="list-item">
<view class="list-check">
<image class="list-image radius" mode="aspectFill" src="http://s2.mogucdn.com/new1/v1/bdefaultavatar/04.jpg"></image>
<wxc-list class="item" title="标题文字" detail="内容描述"></wxc-list>
</view>
<view class="list-check">
<image class="list-image" mode="aspectFill" src="http://s3.mogucdn.com/mlcdn/1689c6/180330_8gak8gf7809jhfi8i0l90i79bca3g_400x400.jpg"></image>
<wxc-list class="item" title="标题文字" detail="内容描述" mode="none"></wxc-list>
</view>
</view>
</view>
</template>
<script>
export default {
config: {
usingComponents: {
'wxc-list': '@minui/wxc-list',
'wxc-icon': '@minui/wxc-icon'
}
},
data: {
check: true
},
/** note: 在 wxp 文件或者页面文件中请去掉 methods 包装 */
methods: {
onCheck() {
let check = this.data.check;
this.setData({
check: !check
})
}
}
}
</script>
<style>
.list-wrap {
width: 100%;
background: #efefef;
padding-bottom: 30rpx;
padding-top: 30rpx;
}
.list-item {
background: #fff;
margin-bottom: 30rpx;
}
.list-item:last-child {
margin: 0;
}
.list-check {
display: flex;
align-items: center
}
.check-wrap {
position: relative;
width: 40rpx;
height: 40rpx;
margin-left: 30rpx;
border-radius: 100%;
border: 1px solid #d8d8d8;
}
.check {
position: absolute;
top: 0;
left: -2rpx;
width: 100%;
height: 100%;
line-height: 42rpx;
}
.list-image {
width: 102rpx;
height: 102rpx;
margin-left: 30rpx;
}
.radius {
border-radius: 100px;
}
.item {
flex: 1;
}
.list-image {
width: 102rpx;
height: 102rpx;
background: #d8d8d8;
}
</style>
API
List
名称 | 描述 |
---|---|
title | [说明]:列表项左侧的标题。[类型]:String [默认值]:"" |
detail | [说明]:标题下方的的详细描述。[类型]:String [默认值]:"" |
desc | [说明]:列表项右侧的描述。[类型]:String [默认值]:"" |
src | [说明]:标题前面的图标,自定义图片链接。优先级高于 icon 。[类型]:String [默认值]:"" |
icon | [说明]:标题前面的图标,类型见 wxc-icon 组件。[类型]:String [默认值]:"" |
icon-color | [说明]:标题前面的icon图标颜色,同 icon 一同使用。[类型]:String [默认值]:#ff5077 |
dot | [说明]:右侧描述部分前面的提醒红点。[类型]:Boolean [默认值]:false |
dot-color | [说明]:右侧描述部分前面的提醒红点颜色,与 dot 一同使用。[类型]:String [默认值]:#f5123e |
arrow | [说明]:是否显示箭头。[类型]:Boolean [默认值]:true |
mode | [说明]:列表项边框模式。[类型]:String [可选值]:normal ,有下边框;none ,无边框。[默认值]:normal |
bind:click | [说明]:点击列表项时触发的事件。组件带 slot 时给组件添加原生事件后点击到 slot 时会报错,故增加自定义事件避免此错误。 |
ChangeLog
v1.0.0(2018-3-29)
- 初始版本