我在import上遇到问题,我有一个像这样的文件:

import { TYPE_CONTRAT_UPDATE, CONFORMITE_UPDATE } from "./actionsTypes";

import { createAction } from "../../../../../../redux/Utilities";

const updateTypeContrat = (idContrat, data, success, error) =>
    createAction(TYPE_CONTRAT_UPDATE.PUT_CALL, { idContrat, data, success,
error });
const updateConformiteContrat = (idContrat, data, success, error) =>
    createAction(CONFORMITE_UPDATE.PUT_CALL, { idContrat, data, success,
error });
export default { updateTypeContrat, updateConformiteContrat};


我正在尝试导入,因为您可以从我的文件actionsTypes中看到大写的变量,这是文件:

import { createPutTypes } from "../../../../../../redux/Utilities";

const TYPE_CONTRAT_UPDATE = createPutTypes("TYPE_CONTRAT_UPDATE");
const CONFORMITE_UPDATE = createPutTypes("CONFORMITE_UPDATE");

export default { CONFORMITE_UPDATE, TYPE_CONTRAT_UPDATE }


但是我得到一个错误:


  第1行:在“ ./actionsTypes”导入/命名中找不到TYPE_CONTRAT_UPDATE
     第1行:在“ ./actionsTypes”导入/命名中找不到CONFORMITE_UPDATE


任何帮助将非常感激。

最佳答案

您需要使用命名的导出而不是默认的。

import { createPutTypes } from "../../../../../../redux/Utilities";

export const TYPE_CONTRAT_UPDATE = createPutTypes("TYPE_CONTRAT_UPDATE");
export const CONFORMITE_UPDATE = createPutTypes("CONFORMITE_UPDATE");

09-17 16:27