screen_rotation
Copied to Clipboard
<!DOCTYPE html> <html> <head> <script src="https://unpkg.com/vue@3.2.22/dist/vue.global.js"></script> </head> <body> <div id="app"> <h1>Vue Js Multiple Ternary Operator Example</h1> <div> {{ isLoggedIn ? (user.role === 'admin' ? 'Welcome, admin!' : (user.role === 'user' ? 'Welcome, user!' : 'Unknown user role.')) : 'Please log in.' }} </div> <input v-model="user.role"> <button @click="isLoggedIn = !isLoggedIn">{{isLoggedIn ? 'Signout': 'LogIn'}}</button> </div> <script type="module"> const app = Vue.createApp({ data() { return { isLoggedIn: false, user: { role: 'user' } } } }) app.mount('#app') </script> <style scoped> #app { display: flex; flex-direction: column; align-items: center; } h1 { font-size: 24px; text-align: center; margin-bottom: 20px; } div { font-size: 18px; margin-bottom: 20px; padding: 10px; border: 1px solid black; } input { font-size: 18px; padding: 10px; margin-bottom: 20px; } button { font-size: 18px; padding: 10px 20px; background-color: blue; color: white; border: none; border-radius: 5px; cursor: pointer; } </style> </body> </html>