Skip to content

Commit e0cad8b

Browse files
committed
Switch to defineModel
1 parent 1f1f66f commit e0cad8b

File tree

2 files changed

+16
-21
lines changed

2 files changed

+16
-21
lines changed

src/RulesModal.vue

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@ import { watchEffect } from 'vue'
33
import BaseButton from './BaseButton.vue'
44
import { DURATION } from './utils.js'
55
6-
const props = defineProps({
7-
visible: {
8-
required: true,
9-
type: Boolean
10-
}
6+
const visible = defineModel('visible', {
7+
required: true,
8+
type: Boolean
119
})
1210
13-
const emit = defineEmits(['update:visible'])
14-
1511
watchEffect(() => {
16-
document.body.style.overflow = props.visible ? 'hidden' : ''
12+
document.body.style.overflow = visible.value ? 'hidden' : ''
1713
})
1814
1915
function close() {
20-
emit('update:visible', false)
16+
visible.value = false
2117
}
2218
</script>
2319

src/SolutionStep.vue

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@ const props = defineProps({
88
stillRemaining: {
99
required: true,
1010
type: Array
11-
},
12-
step: {
13-
required: true,
14-
type: Array
1511
}
1612
})
1713
18-
const emit = defineEmits(['update:step'])
14+
const step = defineModel('step', {
15+
required: true,
16+
type: Array
17+
})
1918
2019
const firstNumIndex = ref(null)
2120
const secondNumIndex = ref(null)
2221
23-
const firstNum = computed(() => props.step[0])
24-
const selectedOp = computed(() => props.step[1])
25-
const secondNum = computed(() => props.step[2])
22+
const firstNum = computed(() => step.value[0])
23+
const selectedOp = computed(() => step.value[1])
24+
const secondNum = computed(() => step.value[2])
2625
2726
const getIndexedNumberList = () => {
2827
return props.stillRemaining.map((value, index) => ({
@@ -104,12 +103,12 @@ watchEffect(() => {
104103
}
105104
})
106105
107-
function updateStep(...step) {
108-
while (step.length && step[step.length - 1] == null) {
109-
step.pop()
106+
function updateStep(...newStep) {
107+
while (newStep.length && newStep[newStep.length - 1] == null) {
108+
newStep.pop()
110109
}
111110
112-
emit('update:step', step)
111+
step.value = newStep
113112
}
114113
115114
function onFirstClick(index) {

0 commit comments

Comments
 (0)