Rico Crivelli
Rico Crivelli

Reputation: 169

How to reset the vue-tel-input input?

I have the following code:

<vue-tel-input ref="telinput" v-model="phone" @input="updatePhone"></vue-tel-input>

and then:

const updatePhone = (event, p) => {
    if (event.constructor.name === "InputEvent") {
        return;
    }
    if (p !== undefined && p.valid) {
        phone.value = p.nationalNumber
        valid.value = true
    } else {
        valid.value = false
        phone.value = ""
    }
}

const addPhone = () => {
    store.mailing.tokens.unshift([
        phone.value,
        variable.value
    ])
    valid.value = false
    phone.value = ""
    window.Toast.fire({
        title: 'Contato adicionado com sucesso!',
        icon: 'success'
    });
}

But the phone variable is never changed by the v-model and when I call the addPhone method the input still showing the phone typed by the user.

Upvotes: 0

Views: 128

Answers (0)

Related Questions