add List
This commit is contained in:
parent
ff71751caa
commit
bc56534b90
10 changed files with 335 additions and 1 deletions
8
src/components/list/index.js
Normal file
8
src/components/list/index.js
Normal file
|
@ -0,0 +1,8 @@
|
|||
import List from './list.vue';
|
||||
import ListItem from './list-item.vue';
|
||||
import ListItemMeta from './list-item-meta.vue';
|
||||
|
||||
List.Item = ListItem;
|
||||
List.Item.Meta = ListItemMeta;
|
||||
|
||||
export default List;
|
35
src/components/list/list-item-meta.vue
Normal file
35
src/components/list/list-item-meta.vue
Normal file
|
@ -0,0 +1,35 @@
|
|||
<template>
|
||||
<div class="ivu-list-item-meta">
|
||||
<div class="ivu-list-item-meta-avatar" v-if="avatar || $slots.avatar">
|
||||
<slot name="avatar">
|
||||
<Avatar :src="avatar" />
|
||||
</slot>
|
||||
</div>
|
||||
<div class="ivu-list-item-meta-content">
|
||||
<div v-if="title || $slots.title" class="ivu-list-item-meta-title"><slot name="title">{{ title }}</slot></div>
|
||||
<div v-if="description || $slots.description" class="ivu-list-item-meta-description"><slot name="description">{{ description }}</slot></div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import Avatar from '../../components/avatar/avatar.vue';
|
||||
|
||||
export default {
|
||||
name: 'ListItemMeta',
|
||||
components: { Avatar },
|
||||
props: {
|
||||
avatar: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
title: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
description: {
|
||||
type: String,
|
||||
default: ''
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
13
src/components/list/list-item.vue
Normal file
13
src/components/list/list-item.vue
Normal file
|
@ -0,0 +1,13 @@
|
|||
<template>
|
||||
<li class="ivu-list-item">
|
||||
<slot></slot>
|
||||
</li>
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
name: 'ListItem',
|
||||
props: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
83
src/components/list/list.vue
Normal file
83
src/components/list/list.vue
Normal file
|
@ -0,0 +1,83 @@
|
|||
<template>
|
||||
<div :class="classes">
|
||||
<div class="ivu-list-header" v-if="header || $slots.header"><slot name="header">{{ header }}</slot></div>
|
||||
<div class="ivu-list-container">
|
||||
<ul class="ivu-list-items"><slot></slot></ul>
|
||||
</div>
|
||||
<Spin v-if="loading"><slot name="spin"></slot></Spin>
|
||||
<div class="ivu-list-footer" v-if="footer || $slots.footer"><slot name="footer">{{ footer }}</slot></div>
|
||||
</div>
|
||||
</template>
|
||||
<script>
|
||||
import { oneOf } from '../../utils/assist';
|
||||
|
||||
const prefixCls = 'ivu-list';
|
||||
|
||||
export default {
|
||||
name: 'List',
|
||||
props: {
|
||||
bordered: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
itemLayout: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['horizontal', 'vertical']);
|
||||
},
|
||||
default: 'horizontal'
|
||||
},
|
||||
// 或 slot
|
||||
header: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 或 slot
|
||||
footer: {
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
// 含 slot: spin
|
||||
loading: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
page: {
|
||||
type: [Boolean, Object],
|
||||
default: false
|
||||
},
|
||||
size: {
|
||||
validator (value) {
|
||||
return oneOf(value, ['small', 'large', 'default']);
|
||||
},
|
||||
default () {
|
||||
return !this.$IVIEW || this.$IVIEW.size === '' ? 'default' : this.$IVIEW.size;
|
||||
}
|
||||
},
|
||||
split: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
},
|
||||
data () {
|
||||
return {
|
||||
|
||||
};
|
||||
},
|
||||
computed: {
|
||||
classes () {
|
||||
return [
|
||||
`${prefixCls}`,
|
||||
`${prefixCls}-${this.size}`,
|
||||
`${prefixCls}-${this.itemLayout}`,
|
||||
{
|
||||
[`${prefixCls}-bordered`]: this.bordered,
|
||||
[`${prefixCls}-split`]: this.split
|
||||
}
|
||||
];
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue