zl程序教程

您现在的位置是:首页 >  前端

当前栏目

uncaught syntaxerror unexpected token U JSON

JSONJSON Token Unexpected SyntaxError Uncaught
2023-09-11 14:14:20 时间

uncaught syntaxerror unexpected token U JSON

The parameter for the JSON.parse may be returning nothing (i.e. the value given for the JSON.parse is undefined)!

It happened to me while I was parsing the Compiled solidity code from an xyz.sol file.

import web3 from './web3';
import xyz from './build/xyz.json';

const i = new web3.eth.Contract(
  JSON.parse(xyz.interface),
  '0x99Fd6eFd4257645a34093E657f69150FEFf7CdF5'
);

export default i;

which was misspelled as

JSON.parse(xyz.intereface)

which was returning nothing!

 

看了一下本地的代码,传递给函数的参数是$('#ctl00_cphMain_ucProfile_Avatar_hffulList').val(),

在Chrome的console的控制台运行,发现返回结果是undefined,

在html里面搜索了一下ctl00_cphMain_ucProfile_Avatar_hffulList,发现这个元素不存在