![](/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.