小编Lio*_*son的帖子

ZF2 - 如何启用Twig的调试/转储功能

有谁知道在ZF2中启用Twig的转储功能的位置?

我看过整个谷歌,我找不到任何真正与这个问题有关的东西.虽然ZFC-Twig模块可以在配置中使用它,但它似乎不是.

谢谢

debugging twig zend-framework2

4
推荐指数
1
解决办法
1003
查看次数

使用 Express.js 时,Node.js ES6 类无法从类方法中调用类方法

铌。这让我有点发疯,我已经在房子周围几次了。但是,我对 ES6 和 JS 整体还是很陌生,并且完全理解 JS 类与其他语言中的类不同,并且可能完全错误地处理这个问题。

我正在运行以下代码,该代码在 Node v8.9.0 上使用 Express.js (v4.16.3) 和 body-parser (v1.18.2)。

app.post('/api/v1/user/update', urlencodedParser, user.update);
Run Code Online (Sandbox Code Playgroud)

代码调用“urlencodedParser”,它充当中间件,为“req”提供“req.body”,以便我可以提取表单字段。'user' 是一个已导出的类模块,包含所有用于验证、更新等的功能,看起来像这样:

class Users {    
    update(req,res) {
        console.log('updating...');
        this.verifyUserIdentity();
    }

    verifyUserIdentity(req,res) {
        console.log('verify');
    }
}

module.exports = new Users;
Run Code Online (Sandbox Code Playgroud)

现在,如果我要在没有 Express 的节点中运行此代码,如下所示:

var users = require('./modules/users');

users.update();
Run Code Online (Sandbox Code Playgroud)

这一切似乎都在执行,我在 CLI 上得到以下输出:

updating...
verify
Run Code Online (Sandbox Code Playgroud)

如果我将它全部打包在app.post()(上面)中并使用 Postman 发送 POST,它会执行第一个方法并在console.log()之后停止,没有错误。似乎没有调用verifyUserIdentity()并且我在 CLI 上得到以下信息:

updating...
Run Code Online (Sandbox Code Playgroud)

如果我修改下面的代码并将一组方法传递给 Express 的中间件处理程序,它似乎可以工作,但现在我必须单独调用verifyUserIdentity(),并没有解决如何调用另一个的问题来自同一类的方法,例如log()方法。

class Users {    
    update(req,res) {
        console.log('updating...');
    }

    verifyUserIdentity(req,res,next) …
Run Code Online (Sandbox Code Playgroud)

node.js express es6-class

1
推荐指数
1
解决办法
766
查看次数

标签 统计

debugging ×1

es6-class ×1

express ×1

node.js ×1

twig ×1

zend-framework2 ×1