Skip to content

为什么对表格进行筛选的时候会重新渲染td的内容 #34

Open

Description

@novazz

使用el-table的时候,我自己写了一个渲染函数来显示表格内的内容,目的是为了显示一些图片或者富文本:
<template slot-scope="cd">
<div v-html="render(cd.row, col.index)" style="display:inline"></div>
</template>
但问题出来了,在对列进行筛选操作的时候,每次展开和关闭筛选选择框,都要调用 render函数,为什么要这样做,这样既没有任何作用,而且还十分低效,有没有什么办法能避免,我看有个filtered-value的列属性好像可以用,但是没看明白是怎么用的

Activity

  1. novazz commented on Aug 21, 2019

    @novazz
    Author

    试了试,就算不对表格进行筛选,我的数据一共只有12条,每条有13列,按理来讲只需要调用12*13=156次渲染函数,但是我利用console统计发现它在初始化的时候就一共调用了624次,不知道是每条还是每列进行了不必要的重复渲染,请问为什么会这样?应该如何避免

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions