本帖最后由 lzynfd 于 2019-1-28 11:22 编辑
react 使用 create-react-app 然后 eject
在一个页面动态创建多个表格。但是编辑其中一个表格其他表格都会被编辑。怎么解决?- <div className={TestPaper["sheets-card"]}>
- <Card title="记账凭证" bordered={false}>
- <SpreadSheets
- workbookInitialized={this.workbookInitialized.bind(this, i, 1)}
- {...spreadSheetsConfig}
- hostStyle={{width: '100%', height: '500px'}}>
- <Worksheet {...worksheetConfig} dataSource={spreadData}>
- </Worksheet>
- </SpreadSheets>
- </Card>
- <Card title="账簿" bordered={false}>
- <SpreadSheets
- workbookInitialized={this.workbookInitialized.bind(this, i, 2)} {...spreadSheetsConfig}
- hostStyle={{width: '100%', height: '500px'}}>
- <Worksheet {...worksheetConfig} dataSource={spreadData}>
- </Worksheet>
- </SpreadSheets>
- </Card>
- </div>
复制代码- workbookInitialized(practicalIndex, spreadIndex, workbook) {
- const keys = `sheet_${practicalIndex}_${spreadIndex}`;
- try {
- let obj = window.spread[keys];
- if (!obj[keys]) {
- practicalObj[keys] = workbook;
- window.spread = practicalObj; // 将spread对象保存在window
- }
- } catch (e) {
- practicalObj[keys] = workbook;
- window.spread = practicalObj; // 将spread对象保存在window
- }
- }
复制代码
|
|