后端如何传递在json中定义函数传递给前端
目录
后端如何传递在json中定义函数传递给前端
后端定义 “{sayHello:"(function(){console.log(“hello”)})”}"
前端处理 JSON.parse(data,function(k,value){
if(value && typeof value === “string” && value.startsWith("(function") && value.endsWith("})"))return eval(value);
return value;
})