【发布时间】:2019-05-31 19:28:05
【问题描述】:
我使用了 create-cep-extension,它是一个基于 create-react-app 构建的 npm。它构建了一个可在任何 Adobe CC 应用程序中运行的引导扩展程序/面板。我在 Adobe Premiere Pro (PPRO) 中使用我的。我不知道如何将道具传递给 index.jsx 中的函数。这个 jsx 文件是 Adobe 的 jsx,它与 react jsx 文件无关,看起来一点也不像。我认为它基本上是一个非常旧的 javascript 版本。
我可以访问 jsx 文件并使用以下命令运行其中的代码:
loadExtendscript('./extendscript/index.jsx');
但我不能以这种方式传递任何道具。
我也可以用这个命令对 PPRO 执行通用的 jsx 命令:
evalExtendscript('alert(app.version)')
这是我将在实际 jsx 文件中使用的典型命令,但我还是不知道如何访问 index.jsx 中的函数并将 props 传递给它。
这是我想要工作的代码:
main.js
let profileObj = {
message: 'ExendScript connected'
};
if (inCEPEnvironment()) {
evalExtendscript('parseObj(' + JSON.stringify(profileObj) + ')')
.then(result => alert(result))
.catch(error => alert(error))
}
index.jsx
function parseObj(obj){
alert(obj.message);
// alert('hello');
};
在过去的两周里,我尝试了所有我能想到的方法,但都没有成功。
这里是 create-cep-extension 文档的链接,其中显示了“evalExtendscript”和“loadExtendscript”的示例: https://github.com/fusepilot/create-cep-extension
【问题讨论】:
标签: reactjs