0

目前,我正在尝试使用 Clockify API ( https://clockify.me/developers-api )为现有的 MantisHub 集成添加功能。我在“src/helpers/integration-helper.js”中添加了函数来操作clockify项目和工作区。我想在“src/integrations/mantishub.js”中引用这些导出的函数,但是当我尝试以下操作时:

import {ProjectExists, createWorkspaceProject} from "../helpers/integration-helper";

(其中 ProjectExists 和 createWorkspaceProjects 是我添加的导出函数。)

我在chrome中收到以下错误:

Uncaught SyntaxError: Unexpected toke {

我不确定我做错了什么(我对 js 比较陌生)。

我尝试过使用动态导入,例如:

var helper_path = '../helpers/integration-helper';

        import(helper_path)
            .then(module => {

                //check if project exists
                var projectExists = module.ProjectExists(project);

                //create the project if it doesn't
                if(projectExists)
                {
                    //create project
                    module.createWorkspaceProject(project);

                    link = clockifyButton.createButton(description, project);
                }
                else
                {
                    link = clockifyButton.createButton(description);
                }
            })
            .catch(err => {

                    //create the button as normal
                    link = clockifyButton.createButton(description);
            });

而是得到以下错误:

Not allowed to load local resource

如何从 mantishub.js 集成中的其他模块导入/访问函数?

谢谢!

编辑 2019 年 9 月 13 日 -

这是 Clockify 应用程序的存储库:

https://github.com/clockify/browser-extension

4

0 回答 0