Created
December 23, 2023 11:05
-
-
Save isaacssemugenyi/90e5faf4696e0d99e2f5fc828808c794 to your computer and use it in GitHub Desktop.
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
<script> | |
import { ref } from 'vue' | |
import AdminItem from './Users/AdminItem.vue' | |
import DistinguishedItem from './Users/DistinguishedItem.vue' | |
import GuestUser from './Users/GuestUser.vue' | |
import SelectItem from './SelectItem.vue' | |
export default { | |
setup() { | |
const user = ref('guest') | |
const setUserChange = (newUser) => (user.value = newUser) | |
return { user, setUserChange } | |
}, | |
components: { | |
SelectItem, | |
AdminItem, | |
DistinguishedItem, | |
GuestUser | |
} | |
} | |
</script> | |
<template> | |
<h1 style="margin-top: 2em">Using IF Statement</h1> | |
<SelectItem @change-user="setUserChange" /> | |
<template v-if="user === 'admin'"> | |
<AdminItem :msg="`${user} information`"> | |
<p style="width: 200px; height: 4vh">I am an {{ user }} user</p> | |
</AdminItem> | |
</template> | |
<template v-else-if="user === 'guest'"> | |
<GuestUser :msg="`${user} information`"> | |
<p style="width: 200px; height: 4vh">I am a {{ user }} user</p> | |
</GuestUser> | |
</template> | |
<template v-else> | |
<DistinguishedItem :msg="`${user} information`"> | |
<p style="width: 200px; height: 4vh">I am a {{ user }} user</p> | |
</DistinguishedItem> | |
</template> | |
</template> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment