Skip to content

Instantly share code, notes, and snippets.

@segovia94
Last active April 19, 2020 01:41
Show Gist options
  • Save segovia94/22a6e3717cf2772401296df27a2e67a4 to your computer and use it in GitHub Desktop.
Save segovia94/22a6e3717cf2772401296df27a2e67a4 to your computer and use it in GitHub Desktop.
hide email vue component
<template>
<div>
<HideEmail :prefix="name" :suffix="mysite.com"/>
</div>
</template>
<script>
import HideEmail from '~/components/HideEmail'
export default {
components: {
HideEmail,
}
}
</script>
<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