staticFile() 不支持相对路径
如果您收到以下错误消息:
staticFile() 不支持相对路径。请传递位于 public/ 文件夹内的文件名。
staticFile() 不支持相对路径。请传递位于 public/ 文件夹内的文件名。
您可能尝试传递相对路径给 staticFile()
:
❌ 相对路径tsx
import {staticFile } from "remotion";staticFile ("../public/image.png");
❌ 相对路径tsx
import {staticFile } from "remotion";staticFile ("../public/image.png");
❌ 文件不应该有 ./ 前缀tsx
import {staticFile } from "remotion";staticFile ("./image.png");
❌ 文件不应该有 ./ 前缀tsx
import {staticFile } from "remotion";staticFile ("./image.png");
或者您可能尝试传递绝对路径:
❌ 文件不应该使用绝对路径tsx
import {staticFile } from "remotion";staticFile ("/Users/bob/remotion-project/public/image.png");
❌ 文件不应该使用绝对路径tsx
import {staticFile } from "remotion";staticFile ("/Users/bob/remotion-project/public/image.png");
或者您可能尝试添加一个不必要的 public/ 前缀:
❌ 文件不应该包含 public/ 前缀tsx
import {staticFile } from "remotion";staticFile ("public/image.png");
❌ 文件不应该包含 public/ 前缀tsx
import {staticFile } from "remotion";staticFile ("public/image.png");
相反,直接传递位于 public 文件夹内的文件名:
✅ 文件名tsx
import {staticFile } from "remotion";staticFile ("image.png");
✅ 文件名tsx
import {staticFile } from "remotion";staticFile ("image.png");