gpt4 book ai didi

mysql - 无法读取 pug/jade 中的属性 'length'

转载 作者:行者123 更新时间:2023-11-29 18:30:55 25 4
gpt4 key购买 nike

我试图在我的哈巴狗代码中创建一个“each”,但运行应用程序后,我收到一条错误消息“无法读取未定义的属性‘长度’”。

这是我的哈巴狗模板代码:

extends ../templates/default

block content
- var item = [];
form.post(action='http://localhost:3000/users/panel', method='post')
img.avatar(src='/img/avatar.jpg', alt='')
input(type='text', name='post', value='', placeholder='Escribe algo')
input(type='submit', value='Publicar')
#card-container
.card
img.avatar(src='/img/avatar.jpg', alt='')
.name='@'+user.nombre
.date='id='+user.id
p.card='Hi!'
table
thead
tr
th # pub
th # user
th Publicacion
tbody
each item in items
tr
td=item.id_publicacion
td=item.id_user
td=item.publicacion

这是我的 Controller :

getPubs: function(req, res, next) {
var config = require('.././database/config');
var db = mysql.createConnection(config);

db.query('SELECT * FROM publicaciones', function(err, rows, fields) {
res.render('panel', {
items: rows
});
});
}

最后这是路由器(我调用电话的地方):

router.get('/users/pubs', controllers.UserController.getPubs);

最佳答案

您在渲染中调用“面板”,但它看起来像是“用户”,所以您必须输入:

getPubs: function(req, res, next) {
var config =require('.././database/config');
var db = mysql.createConnection(config);

db.query('SELECT * FROM publicaciones', function(err, rows, fields) {
res.render('users/panel', {
items: rows
});
});
}

关于mysql - 无法读取 pug/jade 中的属性 'length',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45700649/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com