[新增] avatar 头像组件
This commit is contained in:
9
src/module/avatar/index.ts
Normal file
9
src/module/avatar/index.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
import type { App } from 'vue'
|
||||
import Component from './index.vue'
|
||||
import type { IDefineComponent } from '../type/index'
|
||||
|
||||
Component.install = (app: App) => {
|
||||
app.component(Component.name || 'LayAvatar', Component)
|
||||
}
|
||||
|
||||
export default Component as IDefineComponent
|
||||
14
src/module/avatar/index.vue
Normal file
14
src/module/avatar/index.vue
Normal file
@@ -0,0 +1,14 @@
|
||||
<template>
|
||||
<img :src="src" class="layui-avatar" :class="[radius ? 'layui-avatar-radius':'', size ? 'layui-avatar-' + size: '']"/>
|
||||
</template>
|
||||
|
||||
<script setup name="LayAvatar" lang="ts">
|
||||
import { defineProps } from 'vue'
|
||||
|
||||
const props =
|
||||
defineProps<{
|
||||
src?: boolean
|
||||
radius?: boolean
|
||||
size?: string
|
||||
}>()
|
||||
</script>
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<span :class="classList" :style="styleList">
|
||||
<slot v-if="type != 'dot'"></slot>
|
||||
</span>
|
||||
<span :class="classList" :style="styleList">
|
||||
<slot v-if="type != 'dot'"></slot>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
<script setup name="LayBadge" lang="ts">
|
||||
@@ -9,18 +9,19 @@ import { defineProps } from 'vue'
|
||||
|
||||
const props =
|
||||
defineProps<{
|
||||
type?: string
|
||||
theme?: string
|
||||
color?: string
|
||||
type?: string
|
||||
theme?: string
|
||||
color?: string
|
||||
}>()
|
||||
|
||||
const classList = [{
|
||||
'layui-badge': !props.type,
|
||||
'layui-badge-dot': props.type == 'dot',
|
||||
'layui-badge-rim': props.type == 'rim',
|
||||
},
|
||||
'layui-bg-' + props.theme];
|
||||
|
||||
const styleList = props.color ? 'background-color: ' + props.color : '';
|
||||
const classList = [
|
||||
{
|
||||
'layui-badge': !props.type,
|
||||
'layui-badge-dot': props.type == 'dot',
|
||||
'layui-badge-rim': props.type == 'rim',
|
||||
},
|
||||
'layui-bg-' + props.theme,
|
||||
]
|
||||
|
||||
const styleList = props.color ? 'background-color: ' + props.color : ''
|
||||
</script>
|
||||
Reference in New Issue
Block a user