Skip to main content

staticFile() 不支持远程 URL

如果您收到以下错误消息:

staticFile() 不支持远程 URL。相反,请直接传递 URL,而无需将其包装在 staticFile() 中。
staticFile() 不支持远程 URL。相反,请直接传递 URL,而无需将其包装在 staticFile() 中。

您尝试将远程 URL 传递给 staticFile()。您不需要在 staticFile 中包装路径,可以直接传递:

❌ staticFile() 内部的远程 URL
tsx
import { Img, staticFile } from "remotion";
 
const MyComp = () => {
return <Img src={staticFile("https://example.com/image.png")} />;
};
❌ staticFile() 内部的远程 URL
tsx
import { Img, staticFile } from "remotion";
 
const MyComp = () => {
return <Img src={staticFile("https://example.com/image.png")} />;
};

而是:

✅ 直接传递远程 URL
tsx
import { Img } from "remotion";
 
const MyComp = () => {
return <Img src={"https://example.com/image.png"} />;
};
✅ 直接传递远程 URL
tsx
import { Img } from "remotion";
 
const MyComp = () => {
return <Img src={"https://example.com/image.png"} />;
};

另请参阅