Skip to content

Instantly share code, notes, and snippets.

@earth774
Created March 18, 2019 06:42
Show Gist options
  • Select an option

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

Select an option

Save earth774/f412a5cb3fabea3bdbaf2001045d68d1 to your computer and use it in GitHub Desktop.
2 way data binding all
<!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="app">
<input v-model="message" placeholder="edit me">
<p>Message is: {{ message }}</p>
</div>
<hr />
<div id="app2">
<span>Multiline message is:</span>
<p style="white-space: pre-line;">{{ message }}</p>
<br>
<textarea v-model="message" placeholder="add multiple lines"></textarea>
</div>
<hr />
<div id="app3">
<input type="checkbox" id="checkbox" v-model="checked">
<label for="checkbox">{{ checked }}</label>
</div>
<hr />
<div id='app4'>
<input type="checkbox" id="jack" value="Jack" v-model="checkedNames">
<label for="jack">Jack</label>
<input type="checkbox" id="john" value="John" v-model="checkedNames">
<label for="john">John</label>
<input type="checkbox" id="mike" value="Mike" v-model="checkedNames">
<label for="mike">Mike</label>
<br>
<span>Checked names: {{ checkedNames }}</span>
</div>
<hr />
<div id="app5">
<input type="radio" id="one" value="One" v-model="picked">
<label for="one">One</label>
<br>
<input type="radio" id="two" value="Two" v-model="picked">
<label for="two">Two</label>
<br>
<span>Picked: {{ picked }}</span>
</div>
<hr />
<div id="app6">
<select v-model="selected">
<option disabled value="">Please select one</option>
<option>A</option>
<option>B</option>
<option>C</option>
</select>
<span>Selected: {{ selected }}</span>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
message: 'Amiearth'
}
})
var app2 = new Vue({
el: '#app2',
data: {
message: 'Amiearth'
}
})
var app3 = new Vue({
el: '#app3',
data: {
checked: false
}
})
var app4 = new Vue({
el: '#app4',
data: {
checkedNames: []
}
})
var app5 = new Vue({
el: '#app5',
data: {
picked: ""
}
})
var app6 = new Vue({
el: '#app6',
data: {
selected: ""
}
})
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment