属性是如何被解析的
在渲染期间
🌐 During rendering
Remotion 执行一个算法来确定在渲染视频时传递给你的组件的 props。有三个因素起作用:
🌐 Remotion performs an algorithm for determining the props that are being passed to your component when rendering the video. Three factors play a role:
默认属性 是当没有传递属性给渲染时的回退数据。你可以使用defaultProps 属性来为你的 <Composition />指定它们。输入 props 是在调用渲染时传递的数据,可以通过
inputProps 选项、 --props 标志 或在 Remotion Studio 中使用渲染对话框来传递。 calculateMetadata() 可用于动态转换属性以及组成的元数据。
下图显示了属性是如何被解析的:
🌐 The following diagram shows how the props get resolved:
在 Remotion 工作室
🌐 In the Remotion Studio
在 Remotion Studio 中,props 的解析方式类似,但有一些区别:
默认属性可以在右侧栏中进行编辑 。无效的修改将以红色轮廓标出,并且不会生效。2
如果你使用“渲染”按钮渲染视频, 输入属性表单将会预先填充 默认属性,包括右侧栏中的修改 。
以下规则 保持不变,你应该注意:
如果你使用--props 标志启动 Studio,这些数据将优先于默认属性,包括侧边栏中的修改。通常不建议向 Studio 传递输入属性。 传入的 props 可能会被
calculateMetadata() 转换.