JavaScript使用Jinja模板中呈现的数据引发SyntaxError
SyntaxError: Unexpected token '&'. Expected a property name.
JSON.parse
var obj = JSON.parse({{ data }})for (i in obj){ document.write(obj[i].text + "<br />");}
def get_nodes(node): d = {} if node == "Root": d["text"] = node else: d["text"] = node.name getchildren = get_children(node) if getchildren: d["nodes"] = [get_nodes(child) for child in getchildren] return d tree = get_nodes("Root")return render_template("folder.html", data=tree)
{{ data }}
{'text': 'Root', 'nodes': [{'text': u'Prosjekt3'}, {'text': u'Prosjekt4', 'nodes': [{'text': u'mappe8'}]}]}
天涯尽头无女友
慕慕森
相关分类