简体   繁体   English

流星的项目结构和导入问题

[英]Project structure in meteor and problems with import

I am new to meteor and i use it to create a webgl application for mobile devices. 我是流星的新手,我用它来为移动设备创建一个webgl应用程序。

My problem is the file structure. 我的问题是文件结构。 I already read the manuals so pls dont link to them. 我已经阅读了手册,所以请不要链接到它们。

1.The lib gets loaded first , so i put all my code that should be executed in main.js there?(ig for my webgl project i use a lot of oop, so does it make sense to put my code here?) 1. lib首先被加载,所以我把所有应该在main.js执行的代码main.js那里?(对于我的webgl项目,我用了很多oop,所以把我的代码放在这里有意义吗?)

2.Consider the following structure 2.考虑以下结构 在此处输入图片说明

Everything i use for the webgl application is in the src folder, but if i want to Application.run(); 我用于webgl应用程序的所有内容都在src文件夹中,但是如果我想使用Application.run(); i always get the error Uncaught Error: Cannot find module 'src/Application.js' . 我总是收到错误Uncaught Error: Cannot find module 'src/Application.js' This problem occurs in every folder i put the src folder in, wether it is lib or import or whatever. 在我将src文件夹放入的每个文件夹中,无论它是lib还是import或其他名称,都会出现此问题。

My Application.js looks like this: 我的Application.js看起来像这样:

var Application={};
Application.run = function () {

        //code

}
module.exports = Application;

But what i really want for Application.js is: 但是我真正想要Application.js是:

function Application(){
  //some stuff
}
Application.prototype.run = function(){
   //some stuff
}

So how can i use the second approach of application.js in main.js AND if its not possible how should i do it instead? 那么,如何在main.js使用application.js的第二种方法呢?如果不可能的话,我该怎么做呢?

From your screenshot, it looks like your Application.js file is actually named just Application (without the .js extension). 从屏幕快照中,您的Application.js文件看起来实际上只是命名为Application (没有.js扩展名)。

That may be the reason why your project does not find 'src/Application.js' . 这可能是您的项目找不到'src/Application.js'

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM