-2
我使用Node.js的表达4
我index.js
routes文件我有这个如何从客户端JavaScript的res.render访问本地变量?
router.get('/', function(req, res, next) {
res.render('index', {items: myItemsdocs});
}};
我index.hbs
观点我想使用的物品作为一个javascript变量
var jsItems = items;
var name1 = jsItems[Object.keys(jsItems)[0]].itemName;
alert(name1);
但没有任何反应..我如何使用项目对象我有在客户端JavaScript?
我的模板引擎是快递车把
'变种jsItems = {{items}};' –
@chrisG我试过了,不起作用。 –
http://stackoverflow.com/questions/29174185/accessing-handlebars-variable-inside-client-js-file – Michael