gpt4 book ai didi

javascript - 在 Glitch 中找不到导入 js

转载 作者:太空宇宙 更新时间:2023-11-04 15:28:55 26 4
gpt4 key购买 nike

我使用 Glitch 编写一个 WebVR 项目。如果我直接在views/index.html中设置脚本,效果很好。但是如果我将脚本保存在 js/opencloserawer.js 中并将其导入到 index.html 中。找不到此 .js 文件。该项目在这里: https://glitch.com/edit/#!/skill-lab有人知道原因吗?提前致谢。

<script src="../js/openclosedrawer.js"></script>
<script>
/**
AFRAME.registerComponent('openclosedrawer',{

schema: {
open : {default: '1.8 0 0.1'},
close : {default: '0 0 0.1'},
dur : {default: 300},
closed : {default: "true"}
},

init: function (){
var data= this.data;
var el=this.el;
var closed=true;

var move=document.createElement("a-animation");
move.setAttribute("begin","click");
move.setAttribute("attribute", "position");
move.setAttribute("from", data.close)
move.setAttribute("to", data.open);
move.setAttribute("dur", data.dur);
move.setAttribute("direction", "alternate");

el.appendChild(move);

}
});**/

最佳答案

在您的 server.js 中,您仅公开“public”文件夹

// http://expressjs.com/en/starter/static-files.html
app.use(express.static('public'));

当您将组件路径更改为 public/js/openlinedrawer.js 时,它可以正常工作。我的混音here .

关于javascript - 在 Glitch 中找不到导入 js,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44969036/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com