<template>
<div class="login-container">
<form action="/login" method="post">
<h2>登录</h2>
<div class="form-group">
<label for="username">用户名</label>
<input type="text" id="username" name="username" required>
</div>
<div class="form-group">
<label for="password">密码</label>
<input type="password" id="password" name="password" required>
</div>
<button type="submit" @click="showtel">登录</button>
</form>
</div>
</template>
<script lang="ts">
export default {
name: 'Login',
data() {
return {
username: 'zhangsan',
password: 18,
tel: '138871222222'
}
},
methods:{
showtel(){
alert(this.tel)
}
}
}
</script>
<style scoped>
.login-container {
background: #fff;
padding: 20px;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
width: 300px;
}
.form-group {
margin-bottom: 15px;
}
.form-group label {
display: block;
margin-bottom: 5px;
}
.form-group input {
width: 100%;
padding: 8px;
box-sizing: border-box;
}
button {
width: 100%;
padding: 10px;
background-color: #5cb85c;
border: none;
color: white;
cursor: pointer;
}
button:hover {
background-color: #4cae4c;
}
@media (max-width: 600px) {
.login-container {
width: 90%; /* 在小屏幕上使用更宽的容器 */
}
}
</style>