Commit 0d8ef1936cc64a81425b8a7abb24624ed9b9db1e
1 parent
d8b6a8a4
perf(src/hooks): 增加空保护,tab切换暂时支持单个组件切换
Showing
1 changed file
with
5 additions
and
5 deletions
| ... | ... | @@ -19,11 +19,9 @@ export const useChartInteract = ( |
| 19 | 19 | interactEventOn: string |
| 20 | 20 | ) => { |
| 21 | 21 | /**新增代码 */ |
| 22 | - let combineData: any = null | |
| 23 | 22 | const { |
| 24 | 23 | option: { dataset } |
| 25 | 24 | } = chartConfig |
| 26 | - combineData = dataset | |
| 27 | 25 | const { data } = param |
| 28 | 26 | /**新增代码 */ |
| 29 | 27 | const chartEditStore = useChartEditStore() |
| ... | ... | @@ -46,7 +44,8 @@ export const useChartInteract = ( |
| 46 | 44 | } |
| 47 | 45 | }) |
| 48 | 46 | /**新增代码 */ |
| 49 | - combineData.forEach((combinItem: any, combinIndex: number) => { | |
| 47 | + if (!Array.isArray(dataset)) return | |
| 48 | + dataset.forEach((combinItem: any, combinIndex: number) => { | |
| 50 | 49 | if (itemIndex === combinIndex) { |
| 51 | 50 | combinItem.targetItem = chartEditStore.componentList[index] |
| 52 | 51 | } |
| ... | ... | @@ -54,14 +53,15 @@ export const useChartInteract = ( |
| 54 | 53 | /**新增代码 */ |
| 55 | 54 | }) |
| 56 | 55 | /**新增代码 */ |
| 57 | - combineData.forEach((item: any) => { | |
| 56 | + if (!Array.isArray(dataset)) return | |
| 57 | + dataset.forEach((item: any) => { | |
| 58 | 58 | try { |
| 59 | 59 | if (item.value === data) item.targetItem.status.hide = false |
| 60 | 60 | else { |
| 61 | 61 | item.targetItem.status.hide = true |
| 62 | 62 | } |
| 63 | 63 | } catch (e) { |
| 64 | - console.log(`useChartInteract.hook.ts:${e}`) | |
| 64 | + console.log(`Error: useChartInteract.hook.ts:${e}`) | |
| 65 | 65 | } |
| 66 | 66 | }) |
| 67 | 67 | /**新增代码 */ | ... | ... |