Skip to content

Commit 7e62e50

Browse files
committed
definemodel instead of custom props
1 parent 5994dc5 commit 7e62e50

File tree

1 file changed

+7
-23
lines changed

1 file changed

+7
-23
lines changed

components/ZScaling.vue

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,21 @@
1414
<v-row>
1515
<v-col cols="12" class="py-2">
1616
<v-slider
17-
v-model="localZScale"
17+
v-model="zScale"
1818
:min="1"
1919
:max="10"
2020
:step="0.2"
2121
label="Z Scale"
2222
thumb-label
2323
color="white"
2424
track-color="white"
25-
></v-slider>
25+
/>
2626
</v-col>
2727
</v-row>
2828
<v-row>
2929
<v-col cols="12" class="py-2">
3030
<v-text-field
31-
v-model.number="localZScale"
31+
v-model.number="zScale"
3232
type="number"
3333
label="Z Scale Value"
3434
outlined
@@ -37,7 +37,7 @@
3737
step="0.1"
3838
class="custom-number-input"
3939
:min="1"
40-
></v-text-field>
40+
/>
4141
</v-col>
4242
</v-row>
4343
</v-container>
@@ -54,7 +54,7 @@
5454
<v-btn
5555
variant="outlined"
5656
color="white"
57-
@click="updateZScaling"
57+
@click="$emit('close')"
5858
class="px-4"
5959
>
6060
Apply
@@ -65,26 +65,10 @@
6565
</template>
6666

6767
<script setup>
68+
const zScale = defineModel({ type: Number, default: 1 })
6869
const props = defineProps({
69-
modelValue: Number,
70-
width: { type: Number, required: false, default: 400 },
70+
width: { type: Number, default: 400 },
7171
})
72-
73-
const emit = defineEmits(["update:modelValue", "close"])
74-
75-
const localZScale = ref(Math.max(props.modelValue, 1))
76-
77-
watch(
78-
() => props.modelValue,
79-
(newVal) => {
80-
localZScale.value = Math.max(newVal, 1)
81-
},
82-
)
83-
84-
function updateZScaling() {
85-
emit("update:modelValue", localZScale.value)
86-
emit("close")
87-
}
8872
</script>
8973

9074
<style scoped>

0 commit comments

Comments
 (0)