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

詳解使用element-ui table組件的篩選功能的一個(gè)小坑

 更新時(shí)間:2018年11月02日 11:51:08   作者:技術(shù)肥  
在element ui 框架中,對于table框架,有一個(gè)篩選功能,這篇文章主要介紹了詳解使用element-ui table組件的篩選功能的一個(gè)小坑,非常具有實(shí)用價(jià)值,需要的朋友可以參考下

使用element-ui table組件的篩選功能的一個(gè)小坑

使用自定義模板和篩選功能,一開始的代碼

  <el-table-column v-if="key==='isShow'" label="是否在發(fā)現(xiàn)頁展示" :filters="[{text:'已展示',value: true},{text: '未展示', value: false}]" :filter-method="filterShow">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.isShow">顯示</el-tag>
          <el-tag type="danger" v-else>不顯示</el-tag>
        </template>
      </el-table-column>
      <el-table-column v-else-if="key==='isHandle'" label="是否已經(jīng)審核" :filters="[{text:'已處理',value: true},{text: '未處理', value: false}]" :filter-method="filterHandle">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.isHandle">已處理</el-tag>
          <el-tag type="warning" v-else>未處理</el-tag>
        </template>
      </el-table-column>

然后發(fā)現(xiàn)篩選功能怎么都不能實(shí)現(xiàn),上網(wǎng)查找原因才發(fā)現(xiàn),雖然官網(wǎng)在寫自定義模板的示例代碼時(shí)是這樣的:

<template>
 <el-table
  :data="tableData"
  style="width: 100%">
  <el-table-column
   label="日期"
   width="180">
   <template slot-scope="scope">
    <i class="el-icon-time"></i>
    <span style="margin-left: 10px">{{ scope.row.date }}</span>
   </template>
  </el-table-column>
  <el-table-column
   label="姓名"
   width="180">
   <template slot-scope="scope">
    <el-popover trigger="hover" placement="top">
     <p>姓名: {{ scope.row.name }}</p>
     <p>住址: {{ scope.row.address }}</p>
     <div slot="reference" class="name-wrapper">
      <el-tag size="medium">{{ scope.row.name }}</el-tag>
     </div>
    </el-popover>
   </template>
  </el-table-column>
  <el-table-column label="操作">
   <template slot-scope="scope">
    <el-button
     size="mini"
     @click="handleEdit(scope.$index, scope.row)">編輯</el-button>
    <el-button
     size="mini"
     type="danger"
     @click="handleDelete(scope.$index, scope.row)">刪除</el-button>
   </template>
  </el-table-column>
 </el-table>
</template>

<script>
 export default {
  data() {
   return {
    tableData: [{
     date: '2016-05-02',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1518 弄'
    }, {
     date: '2016-05-04',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1517 弄'
    }, {
     date: '2016-05-01',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1519 弄'
    }, {
     date: '2016-05-03',
     name: '王小虎',
     address: '上海市普陀區(qū)金沙江路 1516 弄'
    }]
   }
  },
  methods: {
   handleEdit(index, row) {
    console.log(index, row);
   },
   handleDelete(index, row) {
    console.log(index, row);
   }
  }
 }
</script>

就是使用scope代替了prop,就是沒有加上prop。

這就是坑所在地方,element的內(nèi)部使用篩選功能時(shí)應(yīng)該是使用到了prop,所以加上prop之后篩選功能就可以用了:

<el-table-column v-if="key==='isShow'" label="是否在發(fā)現(xiàn)頁展示" prop="isShow" :filters="[{text:'已展示',value: true},{text: '未展示', value: false}]" :filter-method="filterShow">
        <template slot-scope="scope">
          <el-tag type="success" v-if="scope.row.isShow">顯示</el-tag>
          <el-tag type="danger" v-else>不顯示</el-tag>
        </template>
      </el-table-column>
      <el-table-column v-else-if="key==='isHandle'" label="是否已經(jīng)審核" prop="isHandle" :filters="[{text:'已處理',value: true},{text: '未處理', value: false}]" :filter-method="filterHandle">
        <template slot-scope="scope">
          <el-tag type="info" v-if="scope.row.isHandle">已處理</el-tag>
          <el-tag type="warning" v-else>未處理</el-tag>
        </template>
      </el-table-column>

使用elementUi 的table組件的篩選功能記得加prop!!!

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue 實(shí)現(xiàn)圖片懶加載功能

    vue 實(shí)現(xiàn)圖片懶加載功能

    這篇文章主要介紹了vue 實(shí)現(xiàn)圖片懶加載功能的方法,幫助大家更好的理解和使用vue,感興趣的朋友可以了解下
    2020-12-12
  • vue.js內(nèi)部自定義指令與全局自定義指令的實(shí)現(xiàn)詳解(利用directive)

    vue.js內(nèi)部自定義指令與全局自定義指令的實(shí)現(xiàn)詳解(利用directive)

    這篇文章主要給大家介紹了關(guān)于vue.js內(nèi)部自定義指令與全局自定義指令的實(shí)現(xiàn)方法,vue.js中實(shí)現(xiàn)自定義指令的主要是利用directive,directive這個(gè)單詞是我們寫自定義指令的關(guān)鍵字,需要的朋友們下面跟著小編來一起學(xué)習(xí)學(xué)習(xí)吧。
    2017-07-07
  • vue-router 按需加載 component: () => import() 報(bào)錯(cuò)的解決

    vue-router 按需加載 component: () => import() 報(bào)錯(cuò)的解決

    這篇文章主要介紹了vue-router 按需加載 component: () => import() 報(bào)錯(cuò)的解決,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-09-09
  • Vue下拉框雙向聯(lián)動(dòng)效果的示例代碼

    Vue下拉框雙向聯(lián)動(dòng)效果的示例代碼

    這篇文章主要介紹了Vue下拉框雙向聯(lián)動(dòng)效果,實(shí)現(xiàn)聯(lián)動(dòng),大家都知道在vue的頁面中,想要實(shí)現(xiàn)多個(gè)<el-select 下拉框的值動(dòng)態(tài)改變,必須要調(diào)用@change 函數(shù),具體操作方法跟隨小編一起學(xué)習(xí)下吧
    2022-04-04
  • Vue實(shí)現(xiàn)無限加載瀑布流

    Vue實(shí)現(xiàn)無限加載瀑布流

    這篇文章主要為大家詳細(xì)介紹了Vue實(shí)現(xiàn)無限加載瀑布流,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-11-11
  • Vue中使用localStorage存儲(chǔ)token并設(shè)置時(shí)效

    Vue中使用localStorage存儲(chǔ)token并設(shè)置時(shí)效

    這篇文章主要為大家介紹了Vue中使用localStorage存儲(chǔ)token并設(shè)置時(shí)效,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-06-06
  • Vue.js中用v-bind綁定class的注意事項(xiàng)

    Vue.js中用v-bind綁定class的注意事項(xiàng)

    關(guān)于數(shù)據(jù)綁定一個(gè)常見需求就是操作元素的class列表和它的內(nèi)聯(lián)樣式。因?yàn)樗鼈兌际菍傩?,我們可以?v-bind 處理它們,但是使用v-bind綁定class的時(shí)候我們要有一些注意事項(xiàng),下面這篇文章就給大家分享了下要注意的方面,希望能對大家有所幫助,下面來一起看看吧。
    2016-12-12
  • vue 項(xiàng)目中實(shí)現(xiàn)按鈕防抖方法

    vue 項(xiàng)目中實(shí)現(xiàn)按鈕防抖方法

    這篇文章主要介紹了vue 項(xiàng)目中實(shí)現(xiàn)按鈕防抖方法,首先需要新建 .js文件存放防抖方法,引入防抖文件,methods中添加方法,本文結(jié)合示例代碼給大家介紹的非常詳細(xì),需要的朋友可以參考下
    2022-12-12
  • vue.js移動(dòng)數(shù)組位置,同時(shí)更新視圖的方法

    vue.js移動(dòng)數(shù)組位置,同時(shí)更新視圖的方法

    下面小編就為大家分享一篇vue.js移動(dòng)數(shù)組位置,同時(shí)更新視圖的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2018-03-03
  • vue router demo詳解

    vue router demo詳解

    這篇文章主要為大家詳細(xì)介紹了vue router demo演示代碼,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-10-10

最新評論