【发布时间】:2015-12-04 07:22:08
【问题描述】:
我的问题
在使用 Meteor JS 时,我遇到了一些我不太确定如何修复的问题,因为所有内容似乎都以正确的顺序加载。它仍然没有以正确的方式行事,它说功能没有定义。
我查看了其他问题,其中大部分是指流星方法部分。我有点困惑,为什么我需要将它包装在 Method 对象中才能使用它们。
我的问题是如何在不使用流星方法调用并将它们作为子对象放入的情况下,将多个函数和“人造”类用作共享的 javascript 文件。
我正在尝试用作共享 js 的示例类。
function CustomerProjects(){
// declare variables
this.name = null;
this.scope = null;
this.time = null;
this.completed = false; // set every project to default false
this.description = null;
// Get the time array
this.billableHours = function(){
if(this.completed){
var totalTime = 0; // int
var time = this.time;
// calculate time
for(var i = 0; i < time.length; i++){
totalTime = totalTime + time[i];
}
return totalTime;
} else {
return "Not Completed";
}
};
}
我的文件结构
【问题讨论】:
标签: javascript meteor