Skip to content

Commit 50cf7ab

Browse files
committed
added watcher to fromat get outside value update
1 parent 0a6f7b1 commit 50cf7ab

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

docs/docs/.vuepress/components/PlayGround.vue

+4
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,10 @@ export default {
168168
methods: {
169169
onChange() {
170170
console.log('onChange', arguments)
171+
// setTimeout(() => {
172+
// this.price = 1500.629
173+
// this.priceDirective = 1500.629
174+
// }, 3000)
171175
},
172176
onInput() {
173177
console.log('onInput', arguments)

src/component.vue

+10-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
/>
1111
</template>
1212
<script lang="ts">
13-
import { defineComponent, ref, computed } from 'vue'
13+
import { defineComponent, ref, computed, watch } from 'vue'
1414
import { cloneDeep, CustomInputEvent, Input } from './core'
1515
import directive from './directive'
1616
import defaultOptions from './options'
@@ -98,6 +98,15 @@ export default defineComponent({
9898
emit('update:model-value', emittedValue.value)
9999
}
100100
101+
watch(
102+
() => props.modelValue,
103+
(newValue, oldValue) => {
104+
if (newValue !== oldValue) {
105+
maskedValue.value = newValue
106+
}
107+
}
108+
)
109+
101110
return {
102111
config,
103112
maskedValue,

0 commit comments

Comments
 (0)