Reactjs 分析错误:意外标记,应为“quot;”&引用;映射函数中的第54行
我有一个错误:解析错误:意外的令牌,应该是“;”在第54行,其中它说fill:false。我不知道我的地图功能出了什么问题。我的渲染函数中有以下代码Reactjs 分析错误:意外标记,应为“quot;”&引用;映射函数中的第54行,reactjs,chart.js,Reactjs,Chart.js,我有一个错误:解析错误:意外的令牌,应该是“;”在第54行,其中它说fill:false。我不知道我的地图功能出了什么问题。我的渲染函数中有以下代码 let forHover = this.state.forHover; let chartData = this.state.chartData; const theData = { labels: ['Scatter'], datasets: [ chartData.map((data, index) => {
let forHover = this.state.forHover;
let chartData = this.state.chartData;
const theData = {
labels: ['Scatter'],
datasets: [
chartData.map((data, index) => {
label: 'Cars From Your Search',
fill: false,
backgroundColor: color[index],
pointBorderColor: color[index],
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: color[index],
pointHoverBorderColor: color[index],
pointHoverBorderWidth: 2,
pointRadius: 5,
pointHitRadius: 5,
data: data
});
]
};
对于箭头函数隐式返回功能,如果要返回对象,必须将该对象括在括号中。否则,它如何知道大括号是对象的包装器,或者它们指示代码块的开始 像这样:
chartData.map((data, index) => ({
label: 'Cars From Your Search',
fill: false,
backgroundColor: color[index],
pointBorderColor: color[index],
pointBackgroundColor: '#fff',
pointBorderWidth: 1,
pointHoverRadius: 5,
pointHoverBackgroundColor: color[index],
pointHoverBorderColor: color[index],
pointHoverBorderWidth: 2,
pointRadius: 5,
pointHitRadius: 5,
data: data
}));
可能重复的