@extends('template')
<script type="text/javascript" src="js/Chart.js"></script>
@section('title')
{{ $student->name }} - Student Detail
@endsection
@section('main')
<div class="container-fluid">
<div class="row">
<div class="col-md-8 col-xs-12" >
<header>
<h3><strong>{{ $student->name }}</strong> <a href="#"><img src="../img/kattis.png" alt="Kattis" width="20" height="15"></a> in CS3233 S1 AY 2020/21</h3>
<p><strong>SPE</strong>(ed) component: <strong>{{ $student->mc }} + {{ $student->tc }} = {{ $student->mc+$student->tc }}</strong><br>
<strong>DIL</strong>(igence) component: <strong>{{ $student->hw }} + {{ $student->bs }} + {{ $student->ks }} + {{ $student->ac }} = {{ $student->hw+$student->bs+$student->ks+$student->ac }}</strong><br>
<strong>Sum = SPE + DIL = {{ $student->mc+$student->tc }} + {{ $student->hw+$student->bs+$student->ks+$student->ac }} = {{ $student->mc+$student->tc+$student->hw+$student->bs+$student->ks+$student->ac }}</strong></p>
</header>
</div>
<div class="col-md-4 hidden-xs hidden-sm">
<img class="pull-right" id="photo" src="@if($student->avatar) {{Storage::url($student->avatar)}} @else ../img/locked.png @endif" alt="Photo of {{ $student->name }}" width="100" height="100">
<img class="pull-right" id="flag" src="../flags/4x3/{{strtolower($student->country)}}.svg" alt="{{$student->country}} Flag" width="100">
</div>
</div>
</div>
<div><canvas id="myChart" width="400" height="400"></canvas></div>
@endsection
@section('footer')
<script>
var ctx = document.getElementById("myChart");
var myChart = new Chart(ctx, {
type: 'radar',
labels: ["MC", "TC", "HW", "Bs", "KS", "Ac"],
data: [$student->mc,$student->tc,$student->hw,$student->bs,$student->ks,$student->ac]
});
</script>
@endsection
在这个名为detail.blade.php
的文件中,我添加了Chart.js
。此文件位于public/js
。 detail.blade.php
位于包含所有其他视图的目录中。在index.blade.php
中,我以完全相同的方式成功引用了javascript文件,例如
@section('footer')
<script type="text/javascript" src="js/highlight.js"></script>
@endsection
。但在detail.blade.php中,它不起作用。我收到有关Failed to load resource: the server responded with a status of 404 (Not Found)
的错误Chart.js
。
有什么问题?
答案 0 :(得分:0)
<script type="text/javascript" src="/js/Chart.js"></script>
此行不构成任何部分的一部分,因此不包括在内。您需要将其包含在某个部分(例如主页或页脚)
答案 1 :(得分:0)
尝试
<script src="{{ URL::asset('/js/Chart.js') }}"></script>
我认为你的js文件夹是公开的,如果你通过这个链接获得了你的脚本。