vuejs嵌套json渲染

时间:2019-12-28 21:23:19

标签: vue.js vuejs2

我必须使用如下所示的json:

 book_json={ "id": 2, "book": "Rockford mountain", "related_json": { "choice0": " The Good Friday Book", "choice1": "DRiven by Inspiration", "choice2": "Do good, be good", "choice3": "Autobiography Obama", "choice4": "None", "select0": "choice0", "select1": "None" } }

在我的模板中,当我渲染时:

{{book_json.book} or {{book_json.id}} # all good 

但是,我想显示的是:

{{book_json.related_json.{{book_json.related_json.select0}} }}
// result: `The Good Friday Book`

即我想选择choice0产生的{{book_json.related_json.select0}}

我花了几个小时尝试和搜索,但找不到找到方法。

任何解决此问题的技巧将不胜感激。

1 个答案:

答案 0 :(得分:1)

尝试:

[[ book_json.related_json[book_json.related_json.select0] ]]