[修复] rate 评分组件
This commit is contained in:
29
src/module/rate/index.less
Normal file
29
src/module/rate/index.less
Normal 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);
|
||||
}
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user