in context.js
const a = require('./context/A'); module.exports = { cache };
in A.js
module.exports = { test(){ const { app } = this; } }
在我的service中如果我使用this.ctx.cache.test 能进入到方法中但是拿不到app了。
但是如果我把context.js内容改成
const a = require('./context/A'); module.exports = cache; 直接导出
在service中使用this.ctx.test 这样在方法体中就可以获取到app了
我不清楚egg在运行的时候是如何绑定this ?