您是否可以在所有云代码方法中使用全局util功能?

时间:2015-04-02 17:26:55

标签: parse-platform

我在每个云代码定义中调用了几个函数,我可以将它们引入全局范围并在所有云代码定义中使用它们吗?

1 个答案:

答案 0 :(得分:0)

是。 Parse使用节点,而节点允许使用模块。 See here

简而言之:

// in some file, lets call it 'cloud/common.js'

exports.foo = function(x) {
    return x+1;
};

// in some other cloud file

var common = require('./common');
var bar = common.foo(1);  // bar will be 2