react前端开发中报错Uncaught SyntaxError: Unexpected token u in JSON at position 0
这是因为JSON.parse转换问题,如果传入的参数不是一个符合要求的字符串就会报错
解决方法
在代码使用到JSON.parse的地方做一个输入参数类型判断:
const contentObj = (contentString !== 'undefined')?JSON.parse(contentString):'';
react前端开发中报错Uncaught SyntaxError: Unexpected token u in JSON at position 0
这是因为JSON.parse转换问题,如果传入的参数不是一个符合要求的字符串就会报错
解决方法
在代码使用到JSON.parse的地方做一个输入参数类型判断:
const contentObj = (contentString !== 'undefined')?JSON.parse(contentString):'';