Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@cursosdesarrolloweb
Created October 3, 2020 14:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cursosdesarrolloweb/f53664f262a95e23e4ef884ec001fbad to your computer and use it in GitHub Desktop.
Save cursosdesarrolloweb/f53664f262a95e23e4ef884ec001fbad to your computer and use it in GitHub Desktop.
Vue.component('computed-properties', {
data () {
return {
name: 'Israel',
surname: 'Parra'
}
},
computed: {
fullName () {
return `${this.name} ${this.surname}`;
}
},
template: `
<div>
<h2>Computed properties</h2>
<p>{{ fullName }}</p>
</div>
`
});
app.component('computed-properties', {
setup() {
const name = ref("Israel");
const surname = ref("Parra");
const fullName = computed(() => {
return `${name.value} ${surname.value}`;
});
return { name, surname, fullName };
},
template: `
<h2>Computed properties en Vue 3</h2>
<p>Nombre: {{ name }} | Apellido: {{ surname }}</p>
<p>Nombre completo: {{ fullName }}</p>
`
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment