Vuejs2.0 + bootstrap demo

來源:互聯網
上載者:User

標籤:div   資料   vuejs   form   ons   ble   lin   bsp   btn   

 

<!DOCTYPE html><html lang="en"><head>  <meta charset="UTF-8">  <link href="../../plugins/bootstrap-3.3.7-dist/css/bootstrap.min.css" rel="stylesheet" type="text/css">  <script src="./vue.js"></script>  <script src="./vue.js"></script>  <script src="../../plugins/jquery-1.9.1.min.js"></script>  <script src="../../plugins/bootstrap-3.3.7-dist/js/bootstrap.min.js"></script>  <title>Vuejs2.0 demo</title></head><body >  <div id="app">    <form action=""  onsubmit="return false;" role="form">      <div class="form-group">        <label class="control-label" for="inputName">姓名:</label>        <div class="controls">          <input type="text" id="inputName" placeholder="輸入姓名" v-model="stu.name" class="form-control">        </div>      </div>      <div class="form-group">        <label class="control-label" for="inputAge">年齡:</label>        <div class="controls">          <input type="text" id="inputAge" placeholder="輸入年齡" v-model="stu.age" class="form-control">        </div>      </div>      <div class="control-group">      <button class="btn btn-small btn-primary"  v-on:click="add();">添加</button>        <button  type="reset" class="btn btn-small btn-danger">重設</button>      </div>    </form>     <table  class="table table-striped table-bordered">       <caption class="h2 text-center">使用者資訊</caption>       <tr><th>序號</th><th>姓名</th><th>年齡</th><th>操作</th></tr>       <!--<tr>       <td>1</td><td>lisi</td><td>20</td><td><button class="btn btn-small">刪除</button></td>       </tr>       <tr>         <td>2</td><td>lisi</td><td>30</td><td><button class="btn btn-small">刪除</button></td>       </tr>-->       <tr v-for="(stu,index) in studata">         <td>{{index + 1}}</td><td>{{ stu.name }}</td><td>{{ stu.age }}</td><td><button class="btn btn-small" v-on:click="del(index);">刪除</button></td>       </tr>       <tr v-show="studata.length!=0">         <td colspan="4" class="text-center">           <button class="btn btn-small btn-danger"   v-on:click="delAll();">全部刪除</button>         </td>       </tr>       <tr v-show="studata.length==0">         <td colspan="4" class="text-center">暫無資料</td>       </tr>     </table>    <!-- <div id="box">       <input type="text" v-model="msg">       <span>{{msg}}</span>     </div>-->  </div>  <script>    window.onload = function(){      new Vue({        el:"#app",        data:{          msg:"使用者資訊表",          studata:[],          stu:{name:"",age:""}        },        methods:{          add:function(){            //this.stu = {name:"lisi",age:"20"};            this.studata.push(this.stu);            this.stu = {};          },          del:function(n){            this.studata.splice(n,1);          },          delAll:function(){            this.studata = [];          }        }      });    }  </script></body></html>

 

Vuejs2.0 + bootstrap demo

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.