户籍管理系统Vue

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>户籍管理系统</title>
<style>
fieldset{
margin: 0 auto;
border:1px solid black;
width:500px;
height:180px;
}

.register{
width:84px;
height:28px;
border:none;
background-color:"black";
border-radius:7px;
color:white;
}

.delone{
width:45px;
height:28px;
border:none;
background-color:"black";
border-radius:7px;
color:white;
}

.table1{
border:1px solid black;
border-collapse:collapse;
width:500px;
height:190px;
margin: 0 auto;


}
th{
border:1px solid black;
font-size:12px;
background-color:gray;
height:25px;

}
.table3{
text-align:center;
font-size:12px;
height:25px;
}
</style>
    
</head>
<body>
<div id="app">
<fieldset>
    <legend>户籍管理系统</legend>
<table id="table2">
    <tr id="name1">
        <td>
            <label>姓名:</label>
            <input type="text" placeholder="请输入用户名" v-model="newperson.name"></input>
        </td>    
    </tr>
    <tr id="age1">
        <td>
            <label>年龄:</label>
            <input type="number" placeholder="请输入年龄" v-model="newperson.age"></input>
        </td>
    </tr>
    <tr id="sex1">
        <td>
            <label>性别:</label>
            <select v-model="newperson.sex">
                <option>男</option>
                <option>女</option>
            </select>
        </td>
    </tr>
    <tr id="phone">
        <td>
            <label>手机:</label>
            <input type="text" placeholder="请输入手机号" v-model="newperson.phone"></input>
        </td>
    </tr>
    
    <tr id="creatNew">
        <td class="register">
            <button @click="addone">创建新用户</button>
        </td>
    </tr>
</table>    
</fieldset>

<br/>
<table class="table1">
    <thead>
        <tr>
            <th>姓名</th>
            <th>性别</th>
            <th>年龄</th>
            <th>手机</th>
            <th>删除</th>
        </tr>
    </thead>
    <tbody class="table3">
        <tr v-for="(item,index) in persons">
            <td>{{item.name}}</td>
            <td>{{item.sex}}</td>
            <td>{{item.age}}</td>
            <td>{{item.phone}}</th>
            <td><button @click="delone(index)">删除</button></td>
        </tr>
    </tbody>
</table>
</div>
<script type="text/javascript" src="https://unpkg.com/vue@2.5.17/dist/vue.js"></script>
<script>
var VM= new Vue({
    el:"#app",
    data:{
        persons:[
        {name:"张三",age:"16",sex:"男",phone:"53163737"},
        {name:"张四",age:"17",sex:"男",phone:"38283738"},
        {name:"张五",age:"18",sex:"女",phone:"83483893"}
        ],
        newperson :{name:"",age:0,sex:"男",phone:""}
    },
    methods:{
        addone(){
            if(!this.newperson.name==''){
            return this.persons.unshift(this.newperson)
            }else{
                alert("不能为空")
            }
        },
        delone(index){
          this.persons.splice(index,1)
        }
    }
});
</script>

</body>
</html>

简单的效果展示:

2a69f0d314c1e277b061946d20b8cd2b847.jpg

我们来增加一条新的用户数据;

e2763cd1cace41b81f35555589d3e4df86e.jpg

点击创建新用户试试;

001d2ffee7753a118a9215f2b5b97628972.jpg

我们来删除一条用户数据;

8df175d856fc95fbc3ecc87e15644b1e8d4.jpg

很简单的功能,是不是挺有趣的呢;

转载于:https://my.oschina.net/u/3995971/blog/2245862

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值