🌸 优化 progress 组件结构

This commit is contained in:
就眠儀式
2021-12-07 16:06:36 +08:00
parent 17480a5ba9
commit a365fb30db
6 changed files with 50 additions and 24 deletions

View File

@@ -1,30 +1,41 @@
<script lang="ts">
export default {
name: "LayProgress",
};
</script>
<script setup lang="ts">
import { computed, defineProps } from "vue";
const props = defineProps<{
percent: number | string;
theme?: string;
color?: string;
size?: string;
showText?: boolean;
text?: string;
}>();
const styles = computed(() => {
return [
props.color ? "background-color: " + props.color : "",
{
width: props.percent + "%",
},
];
});
</script>
<template>
<div class="layui-progress" :class="'layui-progress-' + size">
<div
class="layui-progress-bar"
:class="'layui-bg-' + theme"
:style="[
color ? 'background-color: ' + color : '',
{
width: percent + '%',
},
]"
:style="styles"
>
<span v-if="showText" class="layui-progress-text">
{{ text ? text : percent + '%' }}
{{ text ? text : percent + "%" }}
</span>
</div>
</div>
</template>
<script setup name="LayProgress" lang="ts">
import { defineProps } from 'vue'
const props = defineProps<{
percent: number | string
theme?: string
color?: string
size?: string
showText?: boolean
text?: string
}>()
</script>
</template>