Skip to content

FAQ 常见问题和解决方法

Kagol edited this page Sep 2, 2025 · 1 revision

Angular 项目中使用 @opentiny/fluent-editor 报错

Angular 项目中使用 TinyEditor,未配置 screenshot 模块,执行 npm start 本地启动报错,报错信息:

Error: node_modules/@opentiny/fluent-editor/types/tools/screenshot.d.ts:1:71 - error TS2307: Cannot find module 'html2canvas' or its corresponding type declaration.

import { default as html2canvas, Options as Html2CanvasOptions } from 'html2canvas';

解决方法:

新建文件 src/shims/html2canvas.d.ts

// shims/html2canvas.d.ts 屏蔽引入@opentiny/fluent-editor, 但未安装html2canvas报错
declare module 'html2canvas' {
  // 默认导出的函数
  const html2canvas: (
    element: Element,
    options?: Options
  ) => Promise<HTMLCanvasElement>;

  // 命名空间或接口导出
  namespace html2canvas {
    export interface Options {
      // 根据实际需求定义 Options 的属性
      logging?: boolean;
      imageTimeout?: number;
      // 其他可能的属性...
    }
  }

  // 导出 Options 接口
  export { html2canvas };
  export type Options = html2canvas.Options;
  export default html2canvas;
}

由于未开启 screenshot 功能,因此不需要安装 html2canvas

Clone this wiki locally