大神指点一下,如何调用另一个js文件中的方法(公共方法)

globle.js
cc.Class({
extends: cc.Component,

properties: {
    aa:555,
    getDis:function(p1, p2) {
    var x = p1.x - p2.x;
    var y = p1.y - p2.y;
    var dis = Math.pow((x * x + y * y), 0.5);
    return dis;
},
},

利用require获取
var globle = require(‘globle’);
globle.aa += 20;
globle.getDis(p1,p2);//这里提示“Object doesn’t support property or method ‘getDis’
为什么这里只能获取到那个aa属性,而方法属性不能使用啦,像这样的公共函数该怎么写哟,求大神指点

});

去看官方文档,有引用例子

公共属性和方法直接放在普通对象里就好了,不需要使用cc.Class

let global = {
    aa: 555,
    getDis(p1, p2) {
        let x = p1.x - p2.x;
	let y = p1.y - p2.y;
	let dis = Math.pow((x * x + y * y), 0.5);
	return dis;
    }
}

module.exports = global;

cc.Class返回的是一个function,其实你globle.aa += 20这一句等于globle.aa = undefined + 20,值是NaN

正解,谢谢了