Skip to content

Commit

Permalink
fix(doc-site): img load failed
Browse files Browse the repository at this point in the history
  • Loading branch information
hughfenghen committed Dec 17, 2023
1 parent c9a5f84 commit ce7106c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
7 changes: 4 additions & 3 deletions doc-site/docs/demo/3_1-chromakey-image.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,9 @@ order: 1
```tsx
import React, { useEffect, useState } from 'react';
import { createChromakey } from '@webav/av-cliper';
import { assetsPrefix } from './utils';

const imgSrc = '/img/green-dog.jpeg';
const imgSrc = assetsPrefix(['img/green-dog.jpeg']);

const chromakey = createChromakey({
similarity: 0.4,
Expand All @@ -23,7 +24,7 @@ const chromakey = createChromakey({

async function start(ctx: CanvasRenderingContext2D) {
const img = new Image();
img.src = imgSrc;
img.src = imgSrc[0];
await new Promise((resolve) => {
img.onload = resolve;
});
Expand All @@ -49,7 +50,7 @@ export default function UI() {
return (
<div>
<div>原图</div>
<img src={imgSrc} style={{ width: 500 }} />
<img src={imgSrc[0]} style={{ width: 500 }} />
<div>移除背景</div>
<canvas
width={500}
Expand Down
2 changes: 0 additions & 2 deletions doc-site/docs/demo/utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@



export function assetsPrefix<T extends (string[] | Record<string, string>)>(assetsURL: T): T {
const prefix = process.env.NODE_ENV === 'development' ? '/' : '/WebAV/'
if (Array.isArray(assetsURL)) {
Expand Down

0 comments on commit ce7106c

Please sign in to comment.