Handlebars.js parse object instead of [Object object]

前端 未结 5 636
囚心锁ツ
囚心锁ツ 2020-11-27 16:20

I\'m using Handlebars templates and JSON data is already represented in [Object object], how do I parse this data outside of the Handlebars? For example, I\'m trying to popu

5条回答
  •  猫巷女王i
    2020-11-27 16:51

    You can simple stringify the JSON:

    var user = {}
    user = {'id' : 123, 'name' : 'First Name'};
    // for print
    user.stringify = JSON.stringify(user);
    

    Then in template print by:

    {{{user.stringify}}};
    

提交回复
热议问题