先上错误代码:
this.expandedRowKeys = this.expandedRowKeys.filter(item => {item !== record.index})
这个代码片段使用了花括号 {} 将箭头函数的主体包裹起来。花括号表示函数体的起始和结束,并创建了一个代码块。在这种情况下,由于缺少 return 语句,箭头函数将返回 undefined,而不是条件表达式的结果。
正确的写法是在花括号{}中加return
this.expandedRowKeys = this.expandedRowKeys.filter(item => { return item !== record.index })
或者去掉花括号{},因为箭头函数会隐式返回条件表达式 item !== record.index 的结果。
this.expandedRowKeys = this.expandedRowKeys.filter(item => item !== record.index)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。