需求:點擊左側文件夾樹,自動勾選表格中的對應項
實現:
使用的API:rowSelection,用於進行選擇功能的配置。
使用的參數:selections,自定義選擇配置項。
computed: {
rowSelection() {
const { selectedRowKeys, dataSource } = this
return {
selectedRowKeys, //必須為selectedRowKeys
type: 'radio',
onChange: this.onSelectChange,
selections: [
{
onSelect: () => {
this.selectedRowKeys = [dataSource.length - 1] //控制點擊左側文件夾樹要選中表格的哪一項
}
}
]
}
}
}
點擊左側文件夾樹觸發onSelect方法
onTreeSelect(){
this.rowSelection.selections[0].onSelect()
},