Skip to content

Instantly share code, notes, and snippets.

@Habil99
Last active March 17, 2022 12:00
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 Habil99/2e4c7b4e4d80a193fdc444e0e053c712 to your computer and use it in GitHub Desktop.
Save Habil99/2e4c7b4e4d80a193fdc444e0e053c712 to your computer and use it in GitHub Desktop.
<div class="user">
<input type="text" placeholder="Name" v-model="name" @keypress="setTitle">
<h2>Username: {{ title }}</h2>
</div>
// Vue code You have to code this on javascript file
const user = {
data() {
return {
name: "",
title: ""
}
},
methods: {
setTitle(e) {
if (e.keyCode == 13) {
this.title = this.name
}
}
}
}
Vue.createApp(user).mount("#user");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment