Answer the question
In order to leave comments, you need to log in
How to switch between input and text?
It is necessary to make an input where the full name is entered. After entering, the input disappears, but the entered text remains and a checkmark appears next to it.
Answer the question
In order to leave comments, you need to log in
The two properties are the user input value and the state (input activity). v-if
Either input or span ( / v-else
) is displayed depending on the state . Something like this :
<input v-if="input" v-model="name" @keypress.enter="onEnter">
<span v-else v-text="name" @click="onClick"></span>
data: () => ({
name: '',
input: true,
}),
methods: {
onEnter() {
if (this.name) {
this.input = false;
}
},
onClick() {
this.input = true;
},
},
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question