[Vue.js] Table Row Edit , Add ,Delete
by ShadowKao
HTML
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.2.1/css/bootstrap.min.css"
integrity="sha384-GJzZqFGwb1QTTN6wy59ffF1BuGJpLSa9DkKMp0DgiMDm4iYMj70gZWKYbI706tWS" crossorigin="anonymous">
<title>Vue.js 操作Table新增、刪除並Ajax儲存</title>
<style type="text/css">
body {
padding-top: 30px;
}
[v-cloak] {
display:none !important;
}
</style>
</head>
<body>
<div class="container" id="myApp">
<div class="row">
<div class="col-12">
<div class="clearfix">
<button class="btn btn-info float-right" id="btnAdd" v-on:click="AddRow">新增</button>
</div>
<hr />
<form method="post" action="#">
<table class="table table-striped table-bordered table-hover">
<thead class="thead-light">
<tr>
<th>姓名</th>
<th>職業</th>
<th>性別</th>
<th>是否成年</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<!--通常迴圈中會處理複雜邏輯,必須小心 v-for不足以應付,複雜邏輯須事先在Controller就處理完畢*/-->
<tr v-for="(user,index) in users" v-cloak>
<td>
<!--後端使用v_id資料識別資料-->
<input type="text" class="form-control" name="userName" placeholder="請輸入姓名" v-model="user.userName" />
</td>
<td>
<select class="form-control" name="userJob"...