Vue.js 表单示例:创建简单表单
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Vue Form</title>
<script src='https://cdn.jsdelivr.net/npm/vue'></script>
</head>
<body>
<div id='app'>
<form @submit.prevent='submitForm'>
<label>Name:</label>
<input type='text' v-model='name' required><br><br>
<label>Email:</label>
<input type='email' v-model='email' required><br><br>
<label>Message:</label>
<textarea v-model='message' required></textarea><br><br>
<button type='submit'>Submit</button>
</form>
</div>
<script>
var app = new Vue({
el: '#app',
data: {
name: '',
email: '',
message: ''
},
methods: {
submitForm: function() {
alert('Form submitted!');
// You can add your form submission code here
}
}
})
</script>
</body>
</html>
原文地址: https://www.cveoy.top/t/topic/mXd4 著作权归作者所有。请勿转载和采集!