migrate to composition API and typescript

This commit is contained in:
MaysWind
2025-01-04 16:40:27 +08:00
parent d18e6df1c0
commit e4a50bcd60
+25 -20
View File
@@ -10,31 +10,36 @@
</div> </div>
</template> </template>
<script> <script setup lang="ts">
export default { import { computed } from 'vue';
props: [
'disabled', interface Button {
'buttons', name: string,
'modelValue' value: unknown
], }
emits: [
'update:modelValue' const props = defineProps<{
], modelValue: unknown;
computed: { buttons: Button[];
value: { disabled?: boolean;
get: function () { }>();
return this.modelValue;
const emit = defineEmits<{
(e: 'update:modelValue', value: unknown): void
}>();
const value = computed<unknown>({
get: () => {
return props.modelValue;
}, },
set: function (value) { set: value => {
if (value === this.modelValue) { if (value === props.modelValue) {
return; return;
} }
this.$emit('update:modelValue', value); emit('update:modelValue', value);
} }
} });
}
}
</script> </script>
<style> <style>