🐛(component): 修复 rate 组件 modelValue 缺少响应式

This commit is contained in:
就眠儀式 2022-09-13 06:40:28 +08:00
parent 9d558c798e
commit 800aa23eff
3 changed files with 15 additions and 4 deletions

View File

@ -5,7 +5,7 @@ export default {
</script> </script>
<script setup lang="ts"> <script setup lang="ts">
import { computed, ref, withDefaults } from "vue"; import { computed, ref, watch, withDefaults } from "vue";
import "./index.less"; import "./index.less";
export interface LayRateProps { export interface LayRateProps {
@ -47,6 +47,10 @@ const isHalf = computed(
() => props.half && Math.round(currentValue.value) !== currentValue.value () => props.half && Math.round(currentValue.value) !== currentValue.value
); );
watch(() => props.modelValue, () => {
currentValue.value = props.modelValue;
tempValue.value = props.modelValue;
})
// //
const getValue = function (index: number, event: any): number { const getValue = function (index: number, event: any): number {
if (!props.half) { if (!props.half) {

View File

@ -17,13 +17,17 @@
</template> </template>
<script> <script>
import { ref } from 'vue'; import { ref, onMounted } from 'vue';
export default { export default {
setup() { setup() {
const all1 = ref(0) const all1 = ref(0)
onMounted(() => {
all1.value = 4
})
return { return {
all1 all1
} }

View File

@ -1394,7 +1394,8 @@ export default {
:columns="columns5" :columns="columns5"
:expand-index="1" :expand-index="1"
:data-source="dataSource5" :data-source="dataSource5"
:checkbox="checkbox5" :page="page5" :checkbox="checkbox5"
:page="page5"
:default-toolbar="defaultToolbar5" :default-toolbar="defaultToolbar5"
v-model:selected-keys="selectedKeys5" v-model:selected-keys="selectedKeys5"
@row="rowClick5"> @row="rowClick5">
@ -1403,6 +1404,7 @@ export default {
<lay-button size="sm">删除</lay-button> <lay-button size="sm">删除</lay-button>
</template> </template>
<template v-slot:name="{ data }"> {{data.name}} </template> <template v-slot:name="{ data }"> {{data.name}} </template>
<template v-slot:remark="{ data }"> {{data.remark}} </template>
<template v-slot:name-title>😊</template> <template v-slot:name-title>😊</template>
<template v-slot:birthday="{ data }"> {{data.birthday}} </template> <template v-slot:birthday="{ data }"> {{data.birthday}} </template>
<template v-slot:operator="{ data }"> <template v-slot:operator="{ data }">
@ -1457,8 +1459,9 @@ export default {
}, },
{ {
title:"备注", title:"备注",
width: "300px", width: "100px",
key:"remark", key:"remark",
customSlot:"remark",
ellipsisTooltip: true, ellipsisTooltip: true,
} }
,{ ,{