Skip to content

Instantly share code, notes, and snippets.

@isaacssemugenyi
Created December 24, 2023 06:48
Show Gist options
  • Save isaacssemugenyi/a3d5b3061d6336dbeadabb525ded7734 to your computer and use it in GitHub Desktop.
Save isaacssemugenyi/a3d5b3061d6336dbeadabb525ded7734 to your computer and use it in GitHub Desktop.
// using a switch
const changeComponent = computed(() => {
switch (user.value) {
case 'admin':
return AdminItem
case 'distiguished':
return DistinguishedItem
default:
return GuestUser
}
})
// Using if else
const changeComponent = computed(() => {
if(user.value === 'admin') {
return AdminItem
} else if(user.value === 'distiguished'){
return DistinguishedItem;
} else {
return GuestUser
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment