I used chart.js in Laravel mix in my boostrap.js
import Chart from 'chart.js/auto';
in my blade tamplete
var myChart = window.chart(
$('#chart'),
config,
);
but always get Uncaught ReferenceError: Chart is not defined
The answer it just there
How to install Chart.js in Laravel? ("Uncaught ReferenceError: Chart is not defined")
its very simply we need to declare the Chert in file in a new js file.
create resource/js/loadbefore.js
require('chart.js/dist/chart.js');
in our webpack.mix.js
.js('resources/js/loadbefore.js', 'public/js')
execute npm run dev
after that in our blade tamplete we call loadbefore.js in the head part, an we can use Chart whitout any promblem
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.