Skip to content

Instantly share code, notes, and snippets.

@danomanion
Created March 8, 2019 11:36
Show Gist options
  • Save danomanion/302f9c74edddda7b1d5d4540f88338c2 to your computer and use it in GitHub Desktop.
Save danomanion/302f9c74edddda7b1d5d4540f88338c2 to your computer and use it in GitHub Desktop.
Vue.js - Computed Property
<div id="app">
<h3>Your Name: <input v-model.lazy="userData" /></h3>
<h2 v-if="userData">Initial entry: {{ userData }} </h2>
<h2 v-if="userData">Computed Value: {{ greeting }}</h2>
</div>
new Vue({
el: '#app',
data() {
return {
userData: ''
}
},
computed: {
greeting() {
return `Howdy you are ${this.userData}!`
}
}
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.8/vue.min.js"></script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment