Created
December 24, 2023 06:48
-
-
Save isaacssemugenyi/a3d5b3061d6336dbeadabb525ded7734 to your computer and use it in GitHub Desktop.
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
// 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