python——python传到前端的数据,双引号被转义

 python部分
def mallTemplateConfig(request):
    gameRole_edit = request.session.get('gameRole_edit', []) #获取json串
    return render(request, "operationGL/mallTemplateConfig.html",
                  {
                   'gameRole_edit': json.dumps(gameRole_edit)
                  })

html部分
这样写显示正常,没有问题
    

js部分
这样写json串中的双引号,会被转义成"
console.log("{{ gameRole_edit }}")

用下面这种方法,就可以直接转化json串,不会被转义了
JSON.parse("{{ gameRole_edit|escapejs }}")

你可能感兴趣的:(web)