-
Notifications
You must be signed in to change notification settings - Fork 27
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
Could I use in Element UI? #6
Comments
https://github.com/vuejs-tips/vue-the-mask |
Try this solution. Works for me
Then add to main.js import Inputmask from 'inputmask'
Vue.directive('mask', {
bind: function (el, binding) {
Inputmask(binding.value).mask(el.getElementsByTagName('INPUT')[0])
}
}) Use with <el-input> <el-input
v-model="phone.number"
v-mask="'+7 (999) 999-9999'"
placeholder="+7 (___) ___-____"
></el-input> Inputmask usage https://github.com/RobinHerbots/Inputmask#usage |
Thanks for all, I would like to use mask with |
@matsuev, could example with currency formate, and unmask when get value? |
Now it work for import Inputmask from 'inputmask'
Vue.directive('inputmask', {
bind: function(el, binding) {
var inputs = el.getElementsByTagName('INPUT')
var input = inputs[0]
if (inputs.length > 1) {
input = inputs[inputs.length - 1]
}
// new Inputmask(binding.value).mask(input)
new Inputmask({
autoUnmask: true,
}).mask(input)
},
}) Ex: <el-input
v-model="input"
v-inputmask
data-inputmask="'mask': '+7 (999) 999-9999'"
placeholder="+7 (___) ___-____"
/>
{{ inputJqMask }} But now I am trying with |
but :data-inputmask="{mask: '+7 (999) 999-9999'}" |
I tried a lot of things with directives, but they were all with bugs (because yarn add vue-imask const maskField = (field, maskOptions) => {
const mask = createMask(maskOptions)
return {
get() {
return mask.resolve(this.form[field])
},
set(value) {
this.form[field] = mask.resolve(value)
}
}
}
export default {
data() {
return {
form: {phone: ''},
}
},
computed: {
phoneMasked: maskField('phone', {
mask: '+{7} (000) 000-00-00'
})
}
} p.s. #6 (comment) Fine solution, but not work on mobile devices |
Cause vue-inputmask doesnt work for el-input, I leaved as input and wrapped with
|
I get this error when use your code: |
I've found one more solution:
|
But don't work
The text was updated successfully, but these errors were encountered: