Answer the question
In order to leave comments, you need to log in
Vue.filter works in the first version and doesn't work in the second. What's wrong?
The demo has a character replacement filter, it works fine on the first version, but an error occurs on the second, what am I doing wrong?
And the second question: how best to implement so that the replacement of the character occurs in the same window where the text is written, and not duplicated on another element.
Thanks in advance.
Answer the question
In order to leave comments, you need to log in
The second one gives me an error, what am I doing wrong?
how best to implement so that the replacement of the character occurs in the same window
<textarea v-model="input"></textarea>
data: () => ({
input: '',
}),
watch: {
input(v) {
this.input = v.split('1').join('2');
},
},
<textarea v-model="input" @input="onInput"></textarea>
data: () => ({
input: '',
}),
methods: {
onInput() {
this.input = this.input.split('1').join('2');
},
},
1. Add the input variable to the data section
2. Remove the extra {}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question