集成 prettier 插件, 新增 npm run lint:prettier 命令
This commit is contained in:
@@ -1,29 +1,29 @@
|
||||
.layui-rate,
|
||||
.layui-rate * {
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
display: inline-block;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
.layui-rate {
|
||||
padding: 10px 5px 10px 0;
|
||||
font-size: 0;
|
||||
padding: 10px 5px 10px 0;
|
||||
font-size: 0;
|
||||
}
|
||||
|
||||
.layui-rate li i.layui-icon {
|
||||
font-size: 20px;
|
||||
color: #ffb800;
|
||||
margin-right: 5px;
|
||||
transition: all 0.3s;
|
||||
-webkit-transition: all 0.3s;
|
||||
font-size: 20px;
|
||||
color: #ffb800;
|
||||
margin-right: 5px;
|
||||
transition: all 0.3s;
|
||||
-webkit-transition: all 0.3s;
|
||||
}
|
||||
|
||||
.layui-rate li i:hover {
|
||||
cursor: pointer;
|
||||
transform: scale(1.12);
|
||||
-webkit-transform: scale(1.12);
|
||||
cursor: pointer;
|
||||
transform: scale(1.12);
|
||||
-webkit-transform: scale(1.12);
|
||||
}
|
||||
|
||||
.layui-rate[readonly] li i:hover {
|
||||
cursor: default;
|
||||
transform: scale(1);
|
||||
}
|
||||
cursor: default;
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
<script lang="ts">
|
||||
export default {
|
||||
name: "LayRate",
|
||||
@@ -27,7 +26,11 @@ const props = withDefaults(defineProps<LayRateProps>(), {
|
||||
half: false,
|
||||
text: false,
|
||||
isBlock: false,
|
||||
icons: () => ['layui-icon-rate', 'layui-icon-rate-half', 'layui-icon-rate-solid']
|
||||
icons: () => [
|
||||
"layui-icon-rate",
|
||||
"layui-icon-rate-half",
|
||||
"layui-icon-rate-solid",
|
||||
],
|
||||
});
|
||||
|
||||
const emit = defineEmits(["update:modelValue", "select"]);
|
||||
@@ -36,7 +39,9 @@ const currentValue = ref<number>(props.modelValue);
|
||||
// 临时存储值
|
||||
const tempValue = ref(currentValue.value);
|
||||
// 是否存在半颗星
|
||||
const isHalf = computed(()=>props.half && Math.round(currentValue.value) !== currentValue.value);
|
||||
const isHalf = computed(
|
||||
() => props.half && Math.round(currentValue.value) !== currentValue.value
|
||||
);
|
||||
|
||||
// 计算评分星值
|
||||
const getValue = function (index: number, event: any): number {
|
||||
@@ -89,18 +94,25 @@ const action = function (index: number, event: any) {
|
||||
:class="[
|
||||
'layui-icon',
|
||||
`${
|
||||
icons[icons.length - (isHalf && index === Math.ceil(currentValue) ? 2: 1)]
|
||||
icons[
|
||||
icons.length -
|
||||
(isHalf && index === Math.ceil(currentValue) ? 2 : 1)
|
||||
]
|
||||
}`,
|
||||
]"
|
||||
:style="{ color: theme }"
|
||||
/>
|
||||
<i v-else :class="['layui-icon'].concat(icons[0])" :style="{ color: theme }"/>
|
||||
<i
|
||||
v-else
|
||||
:class="['layui-icon'].concat(icons[0])"
|
||||
:style="{ color: theme }"
|
||||
/>
|
||||
</li>
|
||||
</ul>
|
||||
<template v-if="text">
|
||||
<span class="layui-inline">
|
||||
<slot :value="currentValue">
|
||||
{{ currentValue + '星' }}
|
||||
{{ currentValue + "星" }}
|
||||
</slot>
|
||||
</span>
|
||||
</template>
|
||||
|
||||
Reference in New Issue
Block a user