Created
March 18, 2019 07:53
-
-
Save earth774/372f12dbfceb9d30cc1c0d835501e4a6 to your computer and use it in GitHub Desktop.
Conditional Render
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
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <title>Amiearth</title> | |
| <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> | |
| </head> | |
| <body> | |
| <div id="app5"> | |
| <input type="radio" id="red" value="red" v-model="picked"> | |
| <label for="one">Red</label> | |
| <br> | |
| <input type="radio" id="blue" value="blue" v-model="picked"> | |
| <label for="two">Blue</label> | |
| <br> | |
| <input type="radio" id="green" value="green" v-model="picked"> | |
| <label for="two">Green</label> | |
| <br> | |
| <p v-if="picked == 'red'" style="color:red"> | |
| Red | |
| </p> | |
| <p v-else-if="picked == 'blue'" style="color:blue"> | |
| Blue | |
| </p> | |
| <p v-else style="color:green"> | |
| Green | |
| </p> | |
| <span>Picked: {{ picked }}</span> | |
| </div> | |
| <script> | |
| var app5 = new Vue({ | |
| el: '#app5', | |
| data: { | |
| picked: "" | |
| } | |
| }) | |
| </script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment