Skip to content

Instantly share code, notes, and snippets.

@gkweb
Created November 27, 2020 00:55
Show Gist options
  • Save gkweb/197741d2d71b4c73abec501f69cf9ed9 to your computer and use it in GitHub Desktop.
Save gkweb/197741d2d71b4c73abec501f69cf9ed9 to your computer and use it in GitHub Desktop.
Vue cheats
// computed:
// Dynamic input ID - Useful for inputs / label pairs where there is no requirement to specify the ID
inputId() {
return Math.random().toString(36).substr(2, 5)
}
// Detect if slots available programmatically (no need for prop toggles!)
hasSlot() {
return this.$scopedSlots && typeof this.$scopedSlots.slotName === 'function'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment