12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- <template>
- <ul class="list">
- <li class="header">
- <h3>数据列表</h3>
- <div class="action" v-if="$slots.action">
- <slot name="action"></slot>
- </div>
- </li>
- <ul class="content">
- <li
- v-for="(item, i) in data"
- :key="key ? item[key] : i"
- :class="{select: item.select}"
- @click="$emit('changeSelect', item)"
- >
- <div class="atom-content">
- <slot name="atom" :item="item"></slot>
- </div>
- </li>
- </ul>
- </ul>
- </template>
- <script lang="ts" setup>
- type Item = Record<string, any> & {select?: boolean}
- type ListProps = { title: string, key?: string, data: Array<Item>}
- defineProps<ListProps>()
- defineEmits<{ (e: 'changeSelect', item: Item): void }>()
- </script>
- <style lang="scss" scoped>
- .header {
- border-bottom: 1px solid rgba(255,255,255,0.16);
- display: flex;
- justify-content: space-between;
- padding: 20px;
- h3 {
- font-size: 16px;
- font-weight: bold;
- color: #999999;
- }
- }
- .content {
- li {
- padding: 0 20px;
- cursor: pointer;
- &.select {
- background: rgba(0,200,175,0.1600);
- }
- .atom-content {
- padding: 20px 0;
- border-bottom: 1px solid rgba(255,255,255,0.16);
- }
- }
- }
- .list li {
- list-style: none;
- }
- </style>
|