【问题标题】:loading ammo.js with react.js用 react.js 加载 ammo.js
【发布时间】:2021-05-05 11:34:22
【问题描述】:

我有一个自定义 ammo.js 构建在我想要加载的 reactjs 应用程序中,在 typescript 中。 不幸的是,它不起作用。

我不得不抑制 eslint,更漂亮的是不使用 ammojs api 应用它。

reactjs v16

import * as Ammo from './ammo.js';
Ammo().then (console.log('ammojs loaded'));

我有这个错误:

编译失败
/home/sancelot/git/courbes-simulation/src/components/Child.tsx
/home/sancelot/git/courbes-simulation/src/components/Child.tsx(10,1) 中的 TypeScript 错误:
此表达式不可调用。
类型“typeof Ammo”没有呼叫签名。 TS2349
8 | // @ts-忽略
9 |从 './ammo.js' 导入 * 作为弹药;

10 | Ammo().then (console.log('ammojs loaded'));
| ^
11 |
12 |
13 |类型道具 = {
此错误发生在构建期间,无法消除。

【问题讨论】:

    标签: javascript reactjs typescript ammo.js


    【解决方案1】:

    由于这是一个错误编译,添加@ts-ignore 解决了问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-11-04
      • 2017-10-24
      • 2014-11-21
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 2014-12-21
      相关资源
      最近更新 更多