eslint webpack import Unexpected token
.eslintrc.js配置缺少 "parser": 'babel-eslint', 加上就好了
module.exports = {
"root": true,
"parser": 'babel-eslint',
"env": {
"browser": true,
"node": true
},
"extends": "standard",
"plugins": [
"html"
]
};
nodejs 循环引用JSON序列化错误的解决办法:TypeError: Converting circular structure to JSON
asyncData (context) {
return axios.post('http://xxx.com/style',{
"designId": 1,
})
}
报错JSON.stringify, avoid TypeError: Converting circular structure to JSON
return axios.post返回一个promise,对象嵌套过深可能就解析不出来。
可以 使用 util.inspect 代替 JSON.stringify
var util = require("util")
var a = {};
a.b = a;
a.c = "123";
// console.log(JSON.stringify(a)); // 报错
console.log(util.inspect(a,{depth:null})); //depth:null 展开全部层级
如上代码输出结果
{ b: [Circular], c: '123' }
参考文档:http://stackoverflow.com/questions/11616630/json-stringify-avoid-typeerror-converting-circular-structure-to-json
https://abdulapopoola.com/2017/02/27/what-you-didnt-know-about-json-stringify/