code文章来源:https://www.toymoban.com/news/detail-693270.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="app">
账户:<input type="text" v-model="username"> <br><br>
密码:<input type="password" v-model="password"> <br><br>
<button @click="login">登录</button>
<button @click="reset">重置</button>
</div>
<script src="https://cdn.bootcdn.net/ajax/libs/vue/2.7.14/vue.js"></script>
<script>
const app = new Vue({
el: '#app',
data: {
username: '',
password: '',
},
methods: {
login() {
console.log(this.username + ' ' + this.password);
},
reset() {
this.username = '',
this.password = ''
}
}
})
</script>
</body>
</html>
11
文章来源地址https://www.toymoban.com/news/detail-693270.html
到了这里,关于vue v-model例子的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!