欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue elementui表格獲取某行數(shù)據(jù)(slot-scope和selection-change方法使用)

 更新時(shí)間:2023年01月16日 15:41:36   作者:阿wei程序媛  
這篇文章主要介紹了vue elementui表格獲取某行數(shù)據(jù)(slot-scope和selection-change方法使用),本文通過示例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

效果圖:

1.當(dāng)寫后臺(tái)管理頁(yè)面時(shí),使用element ui里的table表格時(shí),表格中有操作按鈕,獲取當(dāng)前行的數(shù)據(jù)時(shí),我們可以使用 slot-scope="scope"來獲取。

 <el-table-column label="操作" align="center" prop="auditStatus" width="180" fixed="right">
      <template slot-scope="scope">
       <el-button type="text" size="large" @click="audit(scope.row)">審核</el-button>
       </template>
</el-table-column>
  audit(row){
     console.log(row)
    },

打印可得當(dāng)前行數(shù)據(jù),你就可以處理這些數(shù)據(jù)了

 2.但如果要實(shí)現(xiàn)的功能是在表頭上了,例如圖里的批量審核,那要怎么獲取當(dāng)前前勾選的這一行的數(shù)據(jù)呢?這時(shí)我們可以用表格中提供的@selection-change="handleSelectionChange" 的multipleSelection來實(shí)現(xiàn)。

<template>
  <el-table
    ref="multipleTable"
    :data="tableData3"
    tooltip-effect="dark"
    style="width: 100%"
    @selection-change="handleSelectionChange">
    <el-table-column
      type="selection"
      width="55">
    </el-table-column>
    <el-table-column prop="title" label="作品名稱" align="center" width="160">
    </el-table-column>
    <el-table-column prop="count" label="作品數(shù)量" align="center" min-width="160">
    </el-table-column>
    <el-table-column prop="price" label="作品價(jià)格" align="center" min-width="160">
    </el-table-column>
  </el-table>
</template>
 data(){
  return {
    multipleSelection:[]
   }
} 
//獲取所有選擇的項(xiàng)
    handleSelectionChange(val) {
    console.log(val)
      this.multipleSelection = val;
    },

打印可得當(dāng)前行數(shù)據(jù),你就可以處理這些數(shù)據(jù)了

例如: 

<el-form-item>
        <el-button type="primary" @click="batchTransferTip()">批量審核</el-button>
</el-form-item>
    //批量審核
    batchTransferTip() {
      if (this.multipleSelection.length == 0) {
        this.common.messageTip("請(qǐng)選擇要審核的作品", "error");
        return false;
      } else {
        this.editboxName = "verify";
        let planIdList = [];
    //遍歷數(shù)據(jù)
        for (let item of this.multipleSelection) {
          planIdList.push(item.id);
        }
        this.propData.id = planIdList;
      }
    },

注意:this.multipleSelection.length 為選擇了多少項(xiàng)。

拿當(dāng)前選中的行的數(shù)據(jù),進(jìn)行傳值,實(shí)現(xiàn)批量審核功能。

ps:Vue element怎么獲取table表格當(dāng)前行數(shù)據(jù)和索引值

怎么拿表格當(dāng)前行數(shù)據(jù)平時(shí)我們?cè)谑褂帽砀駮r(shí)通過template的slot-scope="scope",使用scope.row拿到當(dāng)前行的數(shù)據(jù)

<el-table max-height="290" :data="userTableData" border style="width: 100%">
      <el-table-column label="名字">
            <template slot-scope="scope">
              {{scope.row.name}}
            </template>
      </el-table-column>
       <el-table-column label="年齡">
            <template slot-scope="{row}">
              {{row.age}}
            </template>
      </el-table-column>
</el-table>

怎么拿表格當(dāng)前行索引值

<el-table max-height="290" :data="userTableData" border style="width: 100%">
      <el-table-column label="序號(hào)">
            <template slot-scope="scope">
                  {{scope.$index+1}} 
            </template>
      </el-table-column>
</el-table>

到此這篇關(guān)于vue elementui表格獲取某行數(shù)據(jù)(slot-scope和selection-change方法使用)的文章就介紹到這了,更多相關(guān)vue elementui表格獲取某行數(shù)據(jù)內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • vue項(xiàng)目中axios使用詳解

    vue項(xiàng)目中axios使用詳解

    這篇文章主要介紹了vue項(xiàng)目中axios使用方法以及原理介紹,如果你正巧學(xué)習(xí)這個(gè)知識(shí)點(diǎn),那么參考下吧。
    2018-02-02
  • Vue實(shí)現(xiàn)一個(gè)無限加載列表功能

    Vue實(shí)現(xiàn)一個(gè)無限加載列表功能

    這篇文章主要介紹了Vue實(shí)現(xiàn)一個(gè)無限加載列表功能,需要的朋友可以參考下
    2018-11-11
  • Vue3.0?axios跨域請(qǐng)求代理服務(wù)器配置方式

    Vue3.0?axios跨域請(qǐng)求代理服務(wù)器配置方式

    這篇文章主要介紹了Vue3.0?axios跨域請(qǐng)求代理服務(wù)器配置方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-04-04
  • WebStorm無法正確識(shí)別Vue3組合式API的解決方案

    WebStorm無法正確識(shí)別Vue3組合式API的解決方案

    這篇文章主要介紹了WebStorm無法正確識(shí)別Vue3組合式API的解決方案,幫助大家更好的理解和學(xué)習(xí)使用vue框架,感興趣的朋友可以了解下
    2021-02-02
  • Vue使用Element折疊面板Collapse如何設(shè)置默認(rèn)全部展開

    Vue使用Element折疊面板Collapse如何設(shè)置默認(rèn)全部展開

    這篇文章主要介紹了Vue使用Element折疊面板Collapse如何設(shè)置默認(rèn)全部展開,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • Vue3全局組件通信之provide?/?inject詳解

    Vue3全局組件通信之provide?/?inject詳解

    這篇文章主要介紹了Vue3全局組件通信之provide?/?inject,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-03-03
  • 在Vue項(xiàng)目中使用自定義字體的操作步驟

    在Vue項(xiàng)目中使用自定義字體的操作步驟

    在項(xiàng)目中使用自定義字體可以提升頁(yè)面的視覺效果,并確保在不同設(shè)備上的一致性,文中通過代碼示例給出了具體的操作步驟,對(duì)大家的學(xué)習(xí)或工作有一定的幫助,需要的朋友可以參考下
    2024-06-06
  • 在vue項(xiàng)目中使用sass的配置方法

    在vue項(xiàng)目中使用sass的配置方法

    這篇文章主要介紹了在vue項(xiàng)目中使用sass的配置方法,需要的朋友可以參考下
    2018-03-03
  • v-for中動(dòng)態(tài)校驗(yàn)el-form表單項(xiàng)的實(shí)踐

    v-for中動(dòng)態(tài)校驗(yàn)el-form表單項(xiàng)的實(shí)踐

    在項(xiàng)目開發(fā)中,我們經(jīng)常會(huì)遇到表單保存的功能,本文主要介紹了v-for中動(dòng)態(tài)校驗(yàn)el-form表單項(xiàng)的實(shí)踐,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧<BR>
    2022-05-05
  • VUE使用docxtemplater導(dǎo)出word文檔實(shí)例(帶圖片)

    VUE使用docxtemplater導(dǎo)出word文檔實(shí)例(帶圖片)

    docxtemplate支持的功能很多,語法包含變量替換、條件判斷、循環(huán)、列表循環(huán)、表格循環(huán)等,下面這篇文章主要給大家介紹了關(guān)于VUE使用docxtemplater導(dǎo)出word功能(帶圖片)的相關(guān)資料,需要的朋友可以參考下
    2023-06-06

最新評(píng)論