Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
有没有办法访问全局注册的插件?我已经阅读了 hapi-sequelize 并且我想将它实现到我的 hapi 应用程序中。这是文档。它在那里声明您可以使用以下代码全局访问它:
var db = plugin.plugins['hapi-sequelized'].models; db.Test.create({ email: 'some@email.com', password: 'alskfjdfoa' });
我尝试将它插入到我的控制器中,但它似乎无法识别插件变量。
您可以在处理程序中访问该插件:
handler: function (request, reply) { var db = request.server.plugins['hapi-sequelized'].models; (...) }