-
-
Save cursosdesarrolloweb/1963216136593da840dd0b497be70c51 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Vue.component('methods', { | |
data () { | |
return { | |
name: 'Israel', | |
surname: 'Parra' | |
} | |
}, | |
computed: { | |
fullName () { | |
return `${this.name} ${this.surname}`; | |
} | |
}, | |
methods: { | |
helloUser () { | |
alert(this.fullName); | |
} | |
}, | |
template: ` | |
<div> | |
<h2>Ejecutar métodos con Vue 2</h2> | |
<p @click="helloUser">Pulsa aquí para ejecutar el método helloUser</p> | |
</div> | |
` | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
app.component('methods', { | |
setup() { | |
const name = ref("Israel"); | |
const surname = ref("Parra"); | |
const fullName = computed(() => { | |
return `${name.value} ${surname.value}`; | |
}); | |
const helloUser = () => { | |
alert(`Hola ${fullName.value}`); | |
} | |
return { helloUser }; | |
}, | |
template: ` | |
<h2>Ejecutar métodos con Vue 3</h2> | |
<p @click="helloUser">Pulsa aquí para ejecutar el método helloUser</p> | |
` | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment