Skip to content

Commit bfc2b32

Browse files
committed
Use :value & @input instead of v-model syntax in Editor***.vue & InputField.vue
1 parent 2122bd6 commit bfc2b32

File tree

4 files changed

+20
-65
lines changed

4 files changed

+20
-65
lines changed

src/components/EditorField.vue

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@
33
<span v-if="title" class="EditorField-Title">{{ title }}</span>
44
<div class="EditorField-Form">
55
<editor-input-field
6-
v-model="modelValue"
6+
:value="value"
77
:label="label"
88
:placeholder="placeholder"
99
:transparent="transparent"
1010
:readonly="readonly"
11+
@input="$emit('input', $event)"
1112
/>
1213
<content-card-editor-button
1314
v-if="iconName"
@@ -24,10 +25,6 @@ import Vue from 'vue'
2425
import EditorInputField from '@/components/EditorInputField.vue'
2526
import ContentCardEditorButton from '@/components/ContentCardEditorButton.vue'
2627
27-
type DataType = {
28-
modelValue: string
29-
}
30-
3128
export default Vue.extend({
3229
components: { EditorInputField, ContentCardEditorButton },
3330
props: {
@@ -66,19 +63,6 @@ export default Vue.extend({
6663
required: false,
6764
default: ''
6865
}
69-
},
70-
data(): DataType {
71-
return {
72-
modelValue: this.value
73-
}
74-
},
75-
watch: {
76-
modelValue(value) {
77-
this.$emit('input', value)
78-
},
79-
value(value) {
80-
this.modelValue = value
81-
}
8266
}
8367
})
8468
</script>

src/components/EditorInputField.vue

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<template>
22
<v-text-field
3-
v-model="modelValue"
3+
:value="value"
44
:color="transparent ? 'white' : '#424242'"
55
type="text"
66
:hint="hint"
@@ -11,14 +11,13 @@
1111
class="elevation-0"
1212
solo
1313
flat
14+
@input="$emit('input', $event)"
1415
/>
1516
</template>
1617

1718
<script lang="ts">
1819
import Vue from 'vue'
19-
type DataType = {
20-
modelValue: string
21-
}
20+
2221
export default Vue.extend({
2322
name: 'InputField',
2423
props: {
@@ -62,19 +61,6 @@ export default Vue.extend({
6261
required: true,
6362
default: ''
6463
}
65-
},
66-
data(): DataType {
67-
return {
68-
modelValue: this.value
69-
}
70-
},
71-
watch: {
72-
modelValue(value) {
73-
this.$emit('input', value)
74-
},
75-
value(value) {
76-
this.modelValue = value
77-
}
7864
}
7965
})
8066
</script>

src/components/EditorTextarea.vue

Lines changed: 2 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,22 @@
22
<div>
33
<span v-if="title" class="EditorTextarea-Title">{{ title }}</span>
44
<v-textarea
5-
v-model="modelValue"
5+
:value="value"
66
:hint="hint"
77
:label="label"
88
:placeholder="placeholder"
99
background-color="white"
1010
class="elevation-0"
1111
solo
1212
flat
13+
@input="$emit('input', $event)"
1314
/>
1415
</div>
1516
</template>
1617

1718
<script lang="ts">
1819
import Vue from 'vue'
1920
20-
type DataType = {
21-
modelValue: string
22-
}
23-
2421
export default Vue.extend({
2522
props: {
2623
title: {
@@ -48,19 +45,6 @@ export default Vue.extend({
4845
required: false,
4946
default: ''
5047
}
51-
},
52-
data(): DataType {
53-
return {
54-
modelValue: this.value
55-
}
56-
},
57-
watch: {
58-
modelValue(value) {
59-
this.$emit('input', value)
60-
},
61-
value(value) {
62-
this.modelValue = value
63-
}
6448
}
6549
})
6650
</script>

src/components/InputField.vue

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<v-text-field
33
v-if="type === 'password'"
4-
v-model="value"
4+
:value="value"
55
:color="textFieldColor"
66
:type="show ? 'text' : 'password'"
77
:hint="hint"
@@ -12,6 +12,7 @@
1212
solo
1313
flat
1414
outlined
15+
@input="$emit('input', $event)"
1516
>
1617
<template v-slot:prepend-inner>
1718
<v-icon :color="prependIconColor">{{ prependIcon }}</v-icon>
@@ -26,7 +27,7 @@
2627
</v-text-field>
2728
<v-text-field
2829
v-else-if="type === 'email'"
29-
v-model="value"
30+
:value="value"
3031
:color="textFieldColor"
3132
type="text"
3233
:hint="hint"
@@ -37,14 +38,15 @@
3738
solo
3839
flat
3940
outlined
41+
@input="$emit('input', $event)"
4042
>
4143
<template v-slot:prepend-inner>
4244
<v-icon :color="prependIconColor">{{ prependIcon }}</v-icon>
4345
</template>
4446
</v-text-field>
4547
<v-text-field
4648
v-else-if="type === 'classId'"
47-
v-model="value"
49+
:value="value"
4850
:color="textFieldColor"
4951
type="text"
5052
:hint="hint"
@@ -55,14 +57,15 @@
5557
solo
5658
flat
5759
outlined
60+
@input="$emit('input', $event)"
5861
>
5962
<template v-slot:prepend-inner>
6063
<v-icon :color="prependIconColor">{{ prependIcon }}</v-icon>
6164
</template>
6265
</v-text-field>
6366
<v-text-field
6467
v-else
65-
v-model="value"
68+
:value="value"
6669
:color="textFieldColor"
6770
type="text"
6871
:hint="hint"
@@ -73,6 +76,7 @@
7376
solo
7477
flat
7578
outlined
79+
@input="$emit('input', $event)"
7680
>
7781
<template v-slot:prepend-inner>
7882
<v-icon :color="prependIconColor">{{ prependIcon }}</v-icon>
@@ -83,12 +87,15 @@
8387
<script lang="ts">
8488
import Vue from 'vue'
8589
type DataType = {
86-
value: string
8790
show: boolean
8891
}
8992
export default Vue.extend({
9093
name: 'InputField',
9194
props: {
95+
value: {
96+
type: String,
97+
default: ''
98+
},
9299
type: {
93100
type: String,
94101
required: false,
@@ -122,8 +129,7 @@ export default Vue.extend({
122129
},
123130
data(): DataType {
124131
return {
125-
show: false,
126-
value: ''
132+
show: false
127133
}
128134
},
129135
computed: {
@@ -182,11 +188,6 @@ export default Vue.extend({
182188
}
183189
return 'mdi-check-circle'
184190
}
185-
},
186-
watch: {
187-
value(value) {
188-
this.$emit('input', value)
189-
}
190191
}
191192
})
192193
</script>

0 commit comments

Comments
 (0)