欢迎来到DIVCSS5查找CSS资料与学习DIV CSS布局技术!
JSON.stringify 不会对函数进行字符串化:
 
实例
 
const person = {
 
  name: "John",
 
  age: function () {return 30;}
 
};
 
let myString = JSON.stringify(person);
 
document.getElementById("demo")。innerHTML = myString;
 
如果在字符串化之前将函数转换为字符串,这可以是“固定的”。
 
This can be "fixed" if you convert the functions into strings before stringifying.
 
实例
 
const person = {
 
  name: "John",
 
  age: function () {return 30;}
 
};
 
person.age = person.age.toString();
 
let myString = JSON.stringify(person);
 
document.getElementById("demo")。innerHTML = myString;

如需转载,请注明文章出处和来源网址:http://www.divcss5.com/html/h64552.shtml