Created
May 27, 2017 00:11
-
-
Save queses/8b008a8b6f7b470cb0a8c5e1788d8c63 to your computer and use it in GitHub Desktop.
An easy solution to solve phone number issue vith VueSSR
This file contains 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> | |
<a :href="`tel: ${this.fPhone}`">{{ fPhone }}</a> | |
</template> | |
<script> | |
export default { | |
props: { | |
phone: { | |
type: [String], | |
required: true | |
} | |
}, | |
computed: { | |
fPhone () { | |
return this.phone.replace(/(\d{1})(\d{3})(\d{3})(\d{2})(\d{2})/, '+$1 ($2) $3-$4-$5') | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment