在线观看不卡亚洲电影_亚洲妓女99综合网_91青青青亚洲娱乐在线观看_日韩无码高清综合久久

鍍金池/ 問(wèn)答/HTML/ 請(qǐng)問(wèn)element-ui table的行數(shù)據(jù)數(shù)據(jù)庫(kù)更新后如何監(jiān)聽數(shù)據(jù)改動(dòng)并刷新呢

請(qǐng)問(wèn)element-ui table的行數(shù)據(jù)數(shù)據(jù)庫(kù)更新后如何監(jiān)聽數(shù)據(jù)改動(dòng)并刷新呢?

template:

  <el-table-column width="130px" align="center" label="狀態(tài)" prop="status">
    <template slot-scope="scope">
      <el-tag :type="scope.row.status | statusFilter">{{scope.row.status}}</el-tag>
    </template>
  </el-table-column>

JS

filters: {
// 狀態(tài)
statusFilter(status) {
  const statusMap = {
    '已處理': 'success',
    '未處理': 'danger'
  }
  return statusMap[status]
},

...

axios.post('api/admin/transaction/updateStatus/id/' + row.id).then((response) => {
  console.log(response)
  if (response.status === 200) {
    this.$message({
      type: 'success',
      message: '處理成功!'
    })
    // 請(qǐng)問(wèn)下面這行如何寫?
    row.status = '已處理' // but not work
  } else {
    this.$message({
      type: 'danger',
      message: '處理失敗!'
    })
  }
})
![圖片描述][1]
數(shù)據(jù)庫(kù)相應(yīng)的數(shù)據(jù)已經(jīng)更新,但是當(dāng)前行的某個(gè)字段狀態(tài)如何更新呢?謝謝!

回答
編輯回答
無(wú)標(biāo)題

代碼有點(diǎn)少不太清楚你的邏輯,暫且我就當(dāng)做你是對(duì)某一行進(jìn)行了操作,然后對(duì)應(yīng)行的狀態(tài)發(fā)生了改變,需要更新對(duì)應(yīng)行的展示情況。

拿到后臺(tái)的返回值的的條件下,及 處理成功的情況下

  1. 直接更改對(duì)應(yīng)行的展示狀態(tài)
  2. 重新調(diào)用請(qǐng)求列表的接口,來(lái)達(dá)到刷新列表的操作。

我們公司項(xiàng)目目前采用的是第二種,至于為什么。。是因?yàn)槊看文玫降亩际呛笈_(tái)的數(shù)據(jù),,前端完全可以甩鍋。。

2018年2月7日 08:25