Skip to content

Instantly share code, notes, and snippets.

@rdegges
Created July 20, 2017 21:37
Show Gist options
  • Save rdegges/859b9a3b2669b6995c5c18c0e5e06e0a to your computer and use it in GitHub Desktop.
Save rdegges/859b9a3b2669b6995c5c18c0e5e06e0a to your computer and use it in GitHub Desktop.
Vue method example.
<html>
<body>
<div id="app">
<p>What's your favorite color?</p>
<input v-model="color" type="text">
<p>Your favorite color is... {{ color }}</p>
<input type="button" v-on:click="capitalizeColor" value="Capitalize">
</div>
<script src="https://unpkg.com/vue"></script>
<script>
let app = new Vue({
el: "#app",
data: {
color: ''
},
methods: {
capitalizeColor: function() {
this.color = this.color.toUpperCase();
}
}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment