RonaldJerez / vue-input-facade

A lightweight and dependency free input masking library created specific for Vue
https://ronaldjerez.github.io/vue-input-facade/latest/
183 stars 27 forks source link

An question about :masked prop #28

Closed iWatchYouFromAfar closed 4 years ago

iWatchYouFromAfar commented 4 years ago

First of all, thanks for the great plugin!

Describe the bug I'm not sure if this is a bug - I would like to receive the raw format of the phone after submitting the form. But somehow it doesn't work ...

To Reproduce Here is my input:

<input
  id="phone"
  v-facade="'+7 (###) ###-##-##'"
  :masked="masked"
  type="tel"
  name="phone"
  placeholder="+7 (___) ___−__−__"
>

Here i am defining parameter masked

data() {
  return {
    input: '',
    masked: false,
  };
},

I also tried to work with props:

  props: {
    masked: {
      type: Boolean,
      default: false,
    },
  },

But when submitting the form - I get the data after processing the mask:

gh

Tell me please - is this a bug or am I doing something wrong?

Thanks!

RonaldJerez commented 4 years ago

Hello, it’s not a bug. You are using the directive which you can’t pass properties to. You would need to use the component version ‘’ then pass the property to that component. If you do need to use the directive version you would have to listen to the input event and get the unmasked value that way. Checkout the demo page, there’s a few usage of both of these scenarios there.

iWatchYouFromAfar commented 4 years ago

Thanks for fast and clear answer!