Last active
April 19, 2020 01:41
-
-
Save segovia94/22a6e3717cf2772401296df27a2e67a4 to your computer and use it in GitHub Desktop.
hide email vue component
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> | |
<div> | |
<HideEmail :prefix="name" :suffix="mysite.com"/> | |
</div> | |
</template> | |
<script> | |
import HideEmail from '~/components/HideEmail' | |
export default { | |
components: { | |
HideEmail, | |
} | |
} | |
</script> |
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> | |
<a v-if="address && show" :href="'mailto:' + address">{{ address }}</a> | |
</template> | |
<script> | |
export default { | |
name: 'HideEmail', | |
data () { | |
return { | |
show: false | |
} | |
}, | |
props: { | |
prefix: String, | |
suffix: String | |
}, | |
computed: { | |
address () { | |
if (this.prefix && this.suffix) { | |
return this.prefix + '@' + this.suffix | |
} else { | |
return false | |
} | |
} | |
}, | |
mounted () { | |
// Show the email if this is the browser | |
if (process.browser) { | |
this.show = true | |
} | |
} | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment