簡體   English   中英

加載外部 javascript 庫

[英]loading external javascript libraries

我正在嘗試在實時服務器上部署一個小型 flask 應用程序,該應用程序還使用 javascript 和一些 Three.js 庫文件。 當嘗試在我的 app.js 文件中導入所需的 three.js 文件時,我收到 404 resource not found 錯誤。 我使用的是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 文件位於 static 文件夾中。 問題是 three.js 庫的尋路。 這三個文件夾位於 js 文件夾內,但由於某種原因找不到它。 任何幫助將不勝感激。

發布確切的錯誤會很有用,但有時如果您添加一個會有所幫助。 在斜線之前,例如import { GUI } from '/js/three/examples/jsm/libs/dat.gui.module.js'; 變成import { GUI } from './js/three/examples/jsm/libs/dat.gui.module.js';

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM