Skip to content

Instantly share code, notes, and snippets.

@earth774
Created March 18, 2019 07:53
Show Gist options
  • Select an option

  • Save earth774/372f12dbfceb9d30cc1c0d835501e4a6 to your computer and use it in GitHub Desktop.

Select an option

Save earth774/372f12dbfceb9d30cc1c0d835501e4a6 to your computer and use it in GitHub Desktop.
Conditional Render
<!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