[修复] rate 评分组件

This commit is contained in:
就眠儀式
2021-11-18 00:45:22 +08:00
parent b817d323f6
commit d0108c63e3
7 changed files with 114 additions and 103 deletions

View File

@@ -0,0 +1,29 @@
.layui-rate,
.layui-rate * {
display: inline-block;
vertical-align: middle;
}
.layui-rate {
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;
}
.layui-rate li i:hover {
cursor: pointer;
transform: scale(1.12);
-webkit-transform: scale(1.12);
}
.layui-rate[readonly] li i:hover {
cursor: default;
transform: scale(1);
}

View File

@@ -1,3 +1,46 @@
<script lang="ts">
export default {
name: "LayRate",
};
</script>
<script setup lang="ts">
import { computed, defineProps, withDefaults } from "vue";
import "./index.less";
export interface LayRateProps {
theme?: string;
length?: number;
modelValue: number;
readonly?: boolean | string;
}
const props = withDefaults(defineProps<LayRateProps>(), {
length: 5,
modelValue: 0,
readonly: false,
});
const emit = defineEmits(["update:modelValue"]);
const currentValue = computed({
get: function () {
return props.modelValue;
},
set: function (val) {
emit("update:modelValue", val);
},
});
const mouseenter = function (index: number, event: any) {
if (props.readonly) {
return false;
}
currentValue.value = index;
};
</script>
<template>
<ul class="layui-rate">
<li
@@ -18,39 +61,3 @@
}}
</ul>
</template>
<script setup lang="ts">
import { computed, defineProps, withDefaults } from 'vue'
const props = withDefaults(
defineProps<{
length?: number
modelValue: number
readonly?: boolean | string
theme?: string
}>(),
{
length: 5,
modelValue: 0,
readonly: false,
theme: 'green',
}
)
const emit = defineEmits(['update:modelValue'])
const currentValue = computed({
get: function () {
return props.modelValue
},
set: function (val) {
emit('update:modelValue', val)
},
})
const mouseenter = function (index: number, event: any) {
if (props.readonly) {
return false
}
currentValue.value = index
}
</script>