-
Notifications
You must be signed in to change notification settings - Fork 213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Example of how to use vue-the-mask with antd #168
Comments
In a more reusable way // masked-input.vue
<template>
<InputMask class="ant-input" :value="value" :mask="mask" @input="change" />
</template>
<script lang="ts">
import { Component, Vue } from 'nuxt-property-decorator'
import { Emit, Model, Prop } from 'vue-property-decorator'
import { TheMask } from 'vue-the-mask'
@Component({
components: {
InputMask: TheMask,
},
})
export default class MaskedInput extends Vue {
@Prop({ type: [String, Array], required: true })
readonly mask!: string | string[]
@Model('change', { type: String })
readonly value!: string
@Emit()
change(value: string) {
return value
}
}
</script> |
1 task
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I'm adding this example as an issue for those who wants to know how to integrate this awesome lib with ant design for vuejs (antd).
If you go to ant input docs you will find an example of a customized form control. If the link does not scroll to the correct doc section, all you just need to do is to search for "Customized Form Controls".
As you can see, to use antd with 3rd party libraries, there are somre requirements that should be follwed:
Here I'll show you how to create a masked input for brazilian phone input numbers and I'll also use class components and typescript but you can quickly convert the code to "pure" vuejs code. So, let's get our hands dirty!
First of all, you need to create an wrapper component to your custom input like this:
And use it in another component!
Here, antd will pass
initialValue
fromv-decorator
to ourBRLPhoneInput
component as aprop
and everything will work perfectly as expected! See demo below.Hope it hepls!
The text was updated successfully, but these errors were encountered: