Created
June 13, 2017 13:49
-
-
Save DawTaylor/aa30458940627e02b5cca879b9a0baae to your computer and use it in GitHub Desktop.
Dynamically binds a mask for optional brazilian cell phone number
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<template lang="pug> | |
form | |
input(type=text)(v-model=celphone)(v-mask=celphoneMask) | |
</template> | |
<script> | |
export default { | |
name: 'mycomponent', | |
data() { | |
return { | |
celphone: '', | |
celphoheMask: '(##) ####-####?#' | |
} | |
}, | |
watch: { | |
celphone: function() { | |
if(this.celphone.length > 14) { | |
this.mask = '(##) #####-####' | |
} else { | |
this.mask = '(##) ####-####?# | |
} | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment