[英]JSHint error: Expected an assignment or function call and instead saw an expression
[英]jshint expected an assignment error
// BAR CHART
if (sparklineType == 'bar') {
barColor = $this.data('sparkline-bar-color') || $this.css('color') || '#0000f0',
sparklineHeight = $this.data('sparkline-height') || '26px',
sparklineBarWidth = $this.data('sparkline-barwidth') || 5,
sparklineBarSpacing = $this.data('sparkline-barspacing') || 2,
sparklineNegBarColor = $this.data('sparkline-negbar-color') || '#A90329',
sparklineStackedColor = $this.data('sparkline-barstacked-color') || ["#A90329", "#0099c6", "#98AA56", "#da532c", "#4490B1", "#6E9461", "#990099", "#B4CAD3"];
$this.sparkline('html', {
barColor : barColor,
type : sparklineType,
height : sparklineHeight,
barWidth : sparklineBarWidth,
barSpacing : sparklineBarSpacing,
stackedBarColor : sparklineStackedColor,
negBarColor : sparklineNegBarColor,
zeroAxis : 'false'
});
}
對於上述JSHINT中的代碼,我收到以下錯誤消息:
“預期了一個賦值或函數調用,而是看到了一個表達式”
有人可以告訴我如何解決此問題嗎?
謝謝!
布爾表達式依靠null或未定義的“虛假”來決定是分配$ this.data還是數組文字。 我的猜測是jshint希望您明確分配值,以便您可以明確檢查$ this.data是否為null或undefined,然后進行相應分配。
錯誤(逗號)
barColor = $this.data('sparkline-bar-color') || $this.css('color') || '#0000f0',
sparklineHeight = $this.data('sparkline-height') || '26px',
sparklineBarWidth = $this.data('sparkline-barwidth') || 5,
sparklineBarSpacing = $this.data('sparkline-barspacing') || 2,
sparklineNegBarColor = $this.data('sparkline-negbar-color') || '#A90329',
sparklineStackedColor = $this.data('sparkline-barstacked-color') || ["#A90329", "#0099c6", "#98AA56", "#da532c", "#4490B1", "#6E9461", "#990099", "#B4CAD3"];
試試這個(分號-;)
barColor = $this.data('sparkline-bar-color') || $this.css('color') || '#0000f0';
sparklineHeight = $this.data('sparkline-height') || '26px';
sparklineBarWidth = $this.data('sparkline-barwidth') || 5;
sparklineBarSpacing = $this.data('sparkline-barspacing') || 2;
sparklineNegBarColor = $this.data('sparkline-negbar-color') || '#A90329';
sparklineStackedColor = $this.data('sparkline-barstacked-color') || ["#A90329", "#0099c6", "#98AA56", "#da532c", "#4490B1", "#6E9461", "#990099", "#B4CAD3"];
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.