鍍金池/ 問(wèn)答/HTML/ element-ui table組件的empty-text屬性怎么沒用?

element-ui table組件的empty-text屬性怎么沒用?

1、想在表格沒有數(shù)據(jù)的地方展示“暫無(wú)”,在文檔中找到了empty-text,結(jié)果不好使是咋回事?

clipboard.png

數(shù)據(jù)中確實(shí)有一部分為空

clipboard.png

但是最后頁(yè)面上還是什么都沒有

clipboard.png

回答
編輯回答
蔚藍(lán)色

你誤解了empty-text的作用,empty-text是表格源數(shù)據(jù)為空時(shí)顯示的內(nèi)容效果是這種效果。
至于想實(shí)現(xiàn)你的需求也有很多種方式,比如這樣

<el-table-column>
  <template slot-scope="{row}">
    {{ row.name || '暫無(wú)' }}
  </template>
</el-table-column>
2018年9月11日 14:58
編輯回答
乖乖噠

謝邀~
看源碼可以發(fā)現(xiàn)你理解錯(cuò)了。是data為空時(shí),顯示empty-text
ElementUI table源碼

<div
    v-if="!data || data.length === 0"
    class="el-table__empty-block"
    ref="emptyBlock"
    :style="{
      width: bodyWidth
    }">
    <span class="el-table__empty-text">
      <slot name="empty">{{ emptyText || t('el.table.emptyText') }}</slot>
    </span>
 </div>
2018年9月21日 22:04