【问题标题】:How to import Javascript file into Ionic/Angular project如何将 Javascript 文件导入 Ionic/Angular 项目
【发布时间】:2017-07-07 13:04:48
【问题描述】:

对于我的 Ionic 2 应用,我使用了 three.js 和 three.js 的 PLYLoader 扩展(可在此处找到:https://github.com/mrdoob/three.js/blob/master/examples/js/loaders/PLYLoader.js

我可以很好地导入三个.js,只要把它放在我的index.html

<script src="three.js"> </script>

然后在相关的 TypeScript 文件中:

import * as THREE from '../../three.js';

所以我正在尝试用 PLYLoader 做同样的事情:

<script src="PLYLoader.js"> </script>

import * as PLYLoader from '../../PLYLoader.js';

但是每当我加载页面时,我都会收到以下错误:

ionViewDidLoad error: __WEBPACK_IMPORTED_MODULE_2__three_js__.PLYLoader is not a constructor

Ionic/Angular 显然能够找到该文件,但由于某种原因,TypeScript 没有正确解释 JavaScript 类。有没有合理的解决办法?

【问题讨论】:

  • 嗨,迈克,我遇到了同样的问题。你的问题解决了吗?

标签: javascript angular typescript ionic2


【解决方案1】:

npm page上,具体有这样的代码:

const THREE = require("three");
const PLYLoader = require("three-ply-loader");
PLYLoader(THREE);

【讨论】:

    【解决方案2】:

    我在 PLYLoader 中没有看到任何导出。这可能是一个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2020-04-02
      • 2017-10-05
      • 2021-08-10
      • 2023-03-15
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多