在 Glitch 中找不到导入 js

import js not found in Glitch

我用 Glitch 写了一个 WebVR 项目。如果我直接在 views/index.html 中设置脚本,效果很好。但是,如果我将脚本保存在 js/openclosedrawer.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/openclosedrawer.js 时,它工作正常。我的混音 here.