加载外部 javascript 个库
loading external javascript libraries
我正在尝试在实时服务器上部署一个小型 Flask 应用程序,该应用程序还使用 javascript 和一些 Three.js 库文件。尝试在我的 app.js 文件中导入所需的 three.js 文件时,出现 404 资源未找到错误。我用的是digitalocean droplet,文件夹结构如下:
app
├── __init__.py
├── static
│ ├── css
│ │ └── style.css
│ ├── js
│ │ └── app.js
| | └── three(folder with all the three library files)
│ └── models
│ └── poly_ann.glb
├── templates
│ └── index.html
└── views.py
app.js 是 index.html 中的“模块”类型。 app.js 的顶部如下所示:
import * as THREE from '/js/three/build/three.module.js';
import { GLTFLoader } from '/js/three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from '/js/three/examples/jsm/loaders/DRACOLoader.js';
import { GUI } from '/js/three/examples/jsm/libs/dat.gui.module.js';
.
.
.
不用说,作为我本地服务器上的纯 html/javascript 应用程序,这些路径工作得很好。
如您所见,app.js 文件位于静态文件夹中,正如所有教程所建议的那样。
问题是 three.js 库的寻路。三个文件夹位于 js 文件夹中,但由于某种原因找不到它。
任何帮助将不胜感激。
post 确切的错误会很有用,但有时添加 .在斜杠之前,例如 import { GUI } from '/js/three/examples/jsm/libs/dat.gui.module.js';
变成 import { GUI } from './js/three/examples/jsm/libs/dat.gui.module.js';
我正在尝试在实时服务器上部署一个小型 Flask 应用程序,该应用程序还使用 javascript 和一些 Three.js 库文件。尝试在我的 app.js 文件中导入所需的 three.js 文件时,出现 404 资源未找到错误。我用的是digitalocean droplet,文件夹结构如下:
app
├── __init__.py
├── static
│ ├── css
│ │ └── style.css
│ ├── js
│ │ └── app.js
| | └── three(folder with all the three library files)
│ └── models
│ └── poly_ann.glb
├── templates
│ └── index.html
└── views.py
app.js 是 index.html 中的“模块”类型。 app.js 的顶部如下所示:
import * as THREE from '/js/three/build/three.module.js';
import { GLTFLoader } from '/js/three/examples/jsm/loaders/GLTFLoader.js';
import { DRACOLoader } from '/js/three/examples/jsm/loaders/DRACOLoader.js';
import { GUI } from '/js/three/examples/jsm/libs/dat.gui.module.js';
.
.
.
不用说,作为我本地服务器上的纯 html/javascript 应用程序,这些路径工作得很好。 如您所见,app.js 文件位于静态文件夹中,正如所有教程所建议的那样。 问题是 three.js 库的寻路。三个文件夹位于 js 文件夹中,但由于某种原因找不到它。 任何帮助将不胜感激。
post 确切的错误会很有用,但有时添加 .在斜杠之前,例如 import { GUI } from '/js/three/examples/jsm/libs/dat.gui.module.js';
变成 import { GUI } from './js/three/examples/jsm/libs/dat.gui.module.js';