我正在使用Adobe After Effects和React Lottie创建动画,我有许多由Bodymovin扩展程序生成的JSON文件。我是这样导入文件的:
import * as initial from './white_bird.json';
import * as hoverOn from './white_bird_hover_on.json';
import * as hoverOff from './white_bird_hover_off.json';
但是,当我有6个其他组件看起来完全相同,唯一的区别在于导入的文件时,我该如何将这些行编写为类似以下内容:
const data = {
initial: import * as initial(`./${some_param}.json`),
};
请注意,我必须像另一种方式中的“* as”一样导入它,否则这将无法正常工作。