ES6 Arrow function is changing the scope of this in Meteor.publish [duplicate]

假如想象 提交于 2019-11-30 13:45:52

This isn't a transpilation error, it's a feature of arrow functions. The arrow function automatically sets the context of the function body to the contexts here it was created, in this case the callback to Meteor.publish. This prevents Meteor from rebinding the context of your listener function.

From the Meteor publish docs:

Inside the function, this is the publish handler object

If you want things to work properly you will need to use the "old-school" function syntax to allow Meteor to set the context properly.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!