登录
注册
node.js 学习社区
node 小白,请教如何在school.js创建1个学校多个班级

xianfacs

2018-05-24 13:06

-----school.js----------报错----------------------------

var banj = require('./index');
//var classx = require('./class');
banj.add([['aaa',[33,44]],['bb',[77,99]]])
-------------------分割线-----------------

--------------index.js----------
var klass = require('./class');
exports.add = function (klasses) {
    console.log('debug_kk:' + klasses)
    klasses.forEach(function (item,index){
        console.log('debug_k:' + item)
        var _klass=item
        var teacherName=item.teacherName
        var students=item.students
        klass.add(teacherName,students)
    })
}

---------teacher.js--------
function add (teacher) {
    console.log('Add Teacher:' + teacher)
};
exports.add = add;

----------student.js-------------
function add (student) {
    console.log('Add Student:' + student)
};
exports.add = add;

--------------class.js----------
var student=require ('./student');
var teacher=require ('./teacher');
function add (teacherName,students){
    console.log('debug_t:' + teacherName)
    console.log('debug_s:' + students)
    teacher.add(teacherName);
    students.forEach(function(item,index){
        student.add(item);
    })
}
exports.add = add;

回复 · 0

发表回复

你可以在回复中 @ 其他人