2018-09-19用户管理

<div class='container'>
   <form action="">
       <div class='form-group'>
           <label for="">用户名</label>
           <input type="text" class='form-control' placeholder="请输入用户名" v-model="student.uname">
       </div>
       <div class='form-group'>
           <label for="">密码</label>
           <input type="text" class='form-control' placeholder="请输入密码" v-model="student.pass">
       </div>
       <div class='form-group'>
           <label for="">邮箱</label>
           <input type="text" class='form-control' placeholder="请输入邮箱" v-model="student.email">
       </div>
       <div class='form-group text-center'>
          <!-- success  绿色    info  蓝色   danger  红色  warning   黄色   primary  蓝色    -->
           <input type="text" class='btn btn-success' value='添加' @click='add'>
           <input type="text" class='btn btn-info' value='重置'>
       </div>
   </form>
   <table class='table table-bordered'>
       <thead>
           <tr>
               <th>编号</th>
               <th>姓名</th>
               <th>密码</th>
               <th>邮箱</th>
               <th>操作</th>
           </tr>
       </thead>
       <tbody>
           <tr v-for="(value,index) in user">
               <td>{{index+1}}</td>
               <td>{{value.uname}}</td>
               <td>{{value.pass}}</td>
               <td>{{value.email}}</td>
               <td>
                   <button @click='delt(index)'>删除</button>
               </td>
           </tr>
       </tbody>
   </table>
</div>

<script src='js/vue.js'></script>
<script>
   
new Vue({
    el:'.container',
    data:{
        user:[
          {uname:'jack',pass:'123456',email:'123@126.com'},
          {uname:'rose',pass:'789456',email:'456@126.com'},
          {uname:'tom',pass:'456321',email:'789@126.com'}
        ],
        student:{}
    },
    methods:{
        add:function(){
            this.user.push(this.student);
            this.student={}
        },
        delt:function(ind){
            this.user.splice(ind,1)
        }
    }
})







</script>
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容