Element: [Bug Report] the selectable of table-column's attributes have an infinite update loop in a component render function.[Vue warn]

Created on 1 Nov 2018  ·  4Comments  ·  Source: ElemeFE/element

Element UI version

2.4.9

OS/Browsers version

macOS Mojave v10.14 (18A391) / Chrome v69.0.3497.100

Vue version

2.5.17

Reproduction Link

https://jsfiddle.net/undefined

Steps to reproduce

  1. to getDataLists and then apply to the table;
  2. set :selectable="checkSelectable" for init default checked status with the row.registered;

What is Expected?

hope the function checkSelectable only execute once per every row

What is actually happening?

the render function checkSelectable may have an infinite update loop

Most helpful comment

你这种写法,如果有10调数据,会循环100次
直接 return !row.registered就可以了吧,为啥要用个this,这里这个this是整个控件了,你所有的row的checkable都绑定到同一个bool对象上当然就来回循环了

All 4 comments

I‘am so sorry for can't apply the valid demo because the network of our company do not have access to https://jsfiddle.net/,but I will use the screenshot to elaborate the situation:
pic1
pic2
pic3

你这种写法,如果有10调数据,会循环100次
直接 return !row.registered就可以了吧,为啥要用个this,这里这个this是整个控件了,你所有的row的checkable都绑定到同一个bool对象上当然就来回循环了

你这种写法,如果有10调数据,会循环100次
直接 return !row.registered就可以了吧,为啥要用个this,这里这个this是整个控件了,你所有的row的checkable都绑定到同一个bool对象上当然就来回循环了

@Eflet 说的对。这种函数应该纯一点,不要有副作用。就像使用 React 时,在 render 函数里修改了 state,当然会造成死循环。

多谢楼上两位的回答,帮我找到问题所在~

Was this page helpful?
0 / 5 - 0 ratings