0
我正在嘗試在帕格代碼中創建一個「每個」,但運行該應用程序後,出現「無法讀取屬性'長度'的未定義」錯誤。無法讀取帕格/玉器中的屬性'長度'
這是我的哈巴狗模板代碼:
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
這是我的控制器:
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);