laravel输出到html json数据时框架默认使用htmlspecialchars 这样确保了数据安全 但是双引号做了转义,因此需要如下处理
function html_decode(str) { var s = ""; if (str.length == 0) return ""; s = str.replace(/&/g, "&"); s = s.replace(/</g, "<"); s = s.replace(/>/g, ">"); s = s.replace(/ /g, " "); s = s.replace(/'/g, "\'"); s = s.replace(/"/g, "\""); s = s.replace(/<br\/>/g, "\n"); return s; } var column = '{{$fields}}'; column = JSON.parse(html_decode(column));