Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/80.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 将值从一个表移动到另一个表_Jquery_Html_Spring_Axios - Fatal编程技术网

Jquery 将值从一个表移动到另一个表

Jquery 将值从一个表移动到另一个表,jquery,html,spring,axios,Jquery,Html,Spring,Axios,我正在使用spring、axios和vue Js将我的数据从mysql显示到一个表中。当我单击表行中的数据时,我能够提醒数据。我想要的是当我单击数据时,它应该出现,或者移动到同一页面中的另一个不同的表或列表中。我如何才能做到这一点。这是我的密码: <table id="myTable" class="display table" width="100%"> <thead> <tr> <th>Account Type</

我正在使用spring、axios和vue Js将我的数据从mysql显示到一个表中。当我单击表行中的数据时,我能够提醒数据。我想要的是当我单击数据时,它应该出现,或者移动到同一页面中的另一个不同的表或列表中。我如何才能做到这一点。这是我的密码:

<table id="myTable" class="display table" width="100%">
  <thead>
    <tr>
      <th>Account Type</th>
      <th>Amount</th>
      <th>Date</th>
      <th>Description</th>
      <th>Action</th>
    </tr>
  </thead>
  <tbody>
    <tr v-for="account in accounts">
      <td>{{account.account_type}}</td>
      <td>{{account.amount}}</td>
      <td>{{account.date}}</td>
      <td>{{account.description}}</td>
      <td><Button v-on:click.prevent="getRowData(account)">Add To List</Button></td>
    </tr>
  </tbody>
</table>
<script type="text/javascript">
  var appVM = new Vue({
        el: '#app',
        data: {
          id: '',
          account_type: '',
          amount: '',
          date: '',
          description: '',
          accounts: Array(),
          rowData: {}

        },
        created: function() {
          this.getAccounts();
        },
        getRowData: function(account) {
          axios.get("/account/" + account.id, ).then(function(response) {
            this.rowData = response.data;
            alert(JSON.stringify(this.rowData))
          }.bind(this))
        }
</script>

要在表外再次显示数据,只需显示rowData即可。我不知道其结构:

<div v-if="rowData">
  <div> {{rowData.accountId}} </div>
  <div> {{rowData.whatever}} </div>
</div>
2当您发出警报时,按下新元素: 单击Accounts.pushthis.rowData

3.把它放在桌子上或类似的地方

<div v-for="clickedAccount in clickedAccounts">
  <div> {{clickedAccount.accountId}} </div>
  <div> {{clickedAccount.whatever}} </div>
</div>

4也许最重要的是:思考、搜索和尝试:

感谢我尝试过的回复,但当我点击它时,它会写入以前的数据。不客气。它是什么意思:它写入以前的数据?它是否显示与警报中相同的数据?我的意思是,当我单击它时,不会添加另一行。它只会替换现有的记录如果您想显示列表而不是最后一个元素,请创建另一个数组,当您单击时,您可以将新元素推入列表,我已更新了答案
<div v-for="clickedAccount in clickedAccounts">
  <div> {{clickedAccount.accountId}} </div>
  <div> {{clickedAccount.whatever}} </div>
</div>