我有一个组件,在
ag-grid-community
。将vue应用程序从lerna移动到NX后,组件的工作方式有所不同。在lerna中包含一些数据的data属性现在为空。没有对应用程序本身进行重大更改,只添加了一些网页配置来处理css。
我怎样才能修复它?或者,如果我做不到,我该如何以不同的方式让它再次发挥作用?
以下是部件代码:
// listColumns.ts used to configure ag-grid
export const columns = {
// ...
actions: {
field: 'actions',
headerName: 'Actions',
cellRenderer: 'Action',
},
}
// Actions.vue
type Params = {
data: any;
value: ActionDefinition[];
};
type ActionDefinition = {
icon: string;
alt: string;
onClick: (data?: any) => void;
};
export default defineComponent({
name: 'Action',
setup() {
const isLoading = ref(true);
const rowData = ref<any>(null);
const actions = ref<ActionDefinition[] | null>(null);
// I've tried to put it here, with no luck
// const instance = getCurrentInstance();
onMounted(() => {
const instance = getCurrentInstance();
if (instance && !isEmpty(instance.data)) { // instance.data is empty - instance.data == {}
const {data, value} = instance.data.params as Params;
rowData.value = data;
actions.value = value;
isLoading.value = false;
}
});
return {isLoading, rowData};
},
});