[Vuejs]-How can use computed for v-model?

0๐Ÿ‘

โœ…

so you can use this solution:

data() {
  return {
    useGet :{
      email: true,
    },
  }
}

in your method:

resetInput(input) {
  this.useGet.email = true
},

and in your computed:

email: {
  get: function () {
    if (this.useGet.email) {
      return UserModule.userInfo ? UserModule.userInfo.usrEmail : ""
    }
    return ""
  },
  set: function (email) {
    this.useGet.email = false
  }
},

0๐Ÿ‘

this is because of your UserModule.userInfo.usrEmail.

this state does not update.
your get in computed will be work when your UserModule.userInfo.usrEmail changes.

Leave a comment