是否可以使用 eval
或类似函数来执行 XD 插件文件内的代码?
最佳答案
来自Adobe XD Platform ...
No.
eval
and similar methods of executing code are disabled. This is for a variety of reasons, including security-related concerns.This doesn’t, however, prevent you from running arbitrary code – it just means you have to get inventive. Before considering this path, however, be sure to consider whether or not you really need to run arbitrary code, as there may be considerable risks to doing so.
一些选项:
- 使用 JavaScript-in-JavaScript 解释器。一些可能的选择:
- 使用数学表达式计算器。一些可能的选择:
- 构建您自己的脚本语言!
- 这假设您喜欢构建解析器、词法分析器等,但对于那些喜欢这样做的人来说,该选项是可用的!
鸣谢: Kerri Shotts来自 Adobe。
关于javascript - 构建 XD 插件时使用 `eval`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53324284/