![](/img/trans.png)
[英]Uncaught SyntaxError: Unexpected token ( error in Javascript
[英]JavaScript Error - Uncaught SyntaxError: Unexpected token {
我試圖在我的laravel應用程序之一中使用Chart JS。
我通過路由推送數據,並使用json_encode($ gross)逐日回顯每個訂單的毛額,但是在控制台日志中出現以下錯誤:
未捕獲到的SyntaxError:意外令牌{
它引用了我使用json_encode($ gross)的行。 任何人都知道為什么會這樣嗎?
Here is the code coming through the controller:
public function index()
{ $wkRevenue = \App\Order::where('created_at', '>=' , \Carbon\Carbon::now()->startOfMonth())->get();
// dd($wkRevenue->pluck('created_at','gross'));
return view('admin.dashboard')
->with('created_at', $wkRevenue->pluck('created_at'))
->with('grosss', $wkRevenue->pluck('gross'));
}
Here is the code in the js file:
var data = {
type:'line',
labels:['Mon','Tues','Wed','Thurs','Fri','Sat','Sun'],
datasets:[
{
data: {!! json_encode($gross) !!},
backgroundColor:'rgba(137, 200, 85, 0.4)',
}
]
}
var graph = document.getElementById('myNewChart').getContext('2d');
var myNewChart = new Chart(graph ,{
type: "line",
data: data,
options:{
title:{
display:true,
}
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.