[英]TypeError: $(…).highcharts is not a function - Existing solutions not working - problems with Yeoman generator
I am following the highcharts get started tutorial here: http://www.highcharts.com/docs/getting-started/your-first-chart 我在这里关注highcharts入门教程: http ://www.highcharts.com/docs/getting-started/your-first-chart
For some reason the code works in a separate HTML file, but not when it's part of my Yeoman built web application 由于某种原因,代码可以在单独的HTML文件中工作,但是在我的Yeoman构建的Web应用程序中却无法使用
I've fallen at the first hurdle and get the following error: TypeError: $(...).highcharts is not a function 我已经跌倒了,遇到以下错误:TypeError:$(...)。highcharts不是一个函数
My code is below and here is the full error: 我的代码在下面,这是完整的错误:
TypeError: $(...).highcharts is not a function at HTMLDocument.eval (eval at ( http://localhost:9000/bower_components/jquery/dist/jquery.js:328:5 ), :2:21) at fire ( http://localhost:9000/bower_components/jquery/dist/jquery.js:3099:30 ) at Object.self.add [as done] ( http://localhost:9000/bower_components/jquery/dist/jquery.js:3145:7 ) at jQuery.fn.ready ( http://localhost:9000/bower_components/jquery/dist/jquery.js:3378:25 ) at jQuery.fn.init ( http://localhost:9000/bower_components/jquery/dist/jquery.js:2821:16 ) at jQuery ( http://localhost:9000/bower_components/jquery/dist/jquery.js:76:10 ) at eval (eval at ( http://localhost:9000/bower_components/jquery/dist/jquery.js:328:5 ), :1:1) at eval (native) at Function.jQuery.extend.globalEval ( http://localhost:9000/bower_components/jquery/dist/jquery.js:328:5 ) at jQuery.fn.extend.domManip ( http://localhost:9000/bower_components/jquery/dist/jquery.js:5435:16 ) TypeError:$(...)。highcharts不是HTMLDocument.eval的函数(eval位于( http:// localhost:9000 / bower_components / jquery / dist / jquery.js:328:5 ) ,:2:21 )在Object.self.add处着火( http:// localhost:9000 / bower_components / jquery / dist / jquery.js:3099:30 )[完成]( http:// localhost:9000 / bower_components / jquery / dist / jQuery.fn.ready上的jquery.js:3145:7 ( http:// localhost:9000 / bower_components / jquery / dist / jquery.js:3378:25 )上jQuery.fn.init( http:// localhost: jQuery( http:// localhost:9000 / bower_components / jquery / dist / jquery.js:76:10 )上的jQuery的9000 / bower_components / jquery / dist / jquery.js:2821:16 )(在( http:/ /localhost:9000/bower_components/jquery/dist/jquery.js:328:5),:1:1 )在Function.jQuery.extend.globalEval( http:// localhost:9000 / bower_components / jquery )的eval(本机) /dist/jquery.js:328:5 ),位于jQuery.fn.extend.domManip( http:// localhost:9000 / bower_components / jquery / dist / jquery.js:5435:16 )
There are multiple other posts about this - however none of the solutions have worked for me, can't see what I'm doing wrong here, all I've done is copy the tutorial. 关于此的其他文章很多 -但是,没有一种解决方案对我有用,在这里看不到我在做什么错,我所做的只是复制了本教程。
Here is my HTML file: 这是我的HTML文件:
<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script>$(function () {
$('#container').highcharts({
chart: {
type: 'bar'
},
title: {
text: 'Fruit Consumption'
},
xAxis: {
categories: ['Apples', 'Bananas', 'Oranges']
},
yAxis: {
title: {
text: 'Fruit eaten'
}
},
series: [{
name: 'Jane',
data: [1, 0, 4]
}, {
name: 'John',
data: [5, 7, 3]
}]
});
});</script>
</head>
<body>
<div id="container" style="width:100%; height:400px;"></div>
</body>
</html>
<!DOCTYPE html> <html> <head> <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script> <script src="http://code.highcharts.com/highcharts.js"></script> <script>$(function () { $('#container').highcharts({ chart: { type: 'bar' }, title: { text: 'Fruit Consumption' }, xAxis: { categories: ['Apples', 'Bananas', 'Oranges'] }, yAxis: { title: { text: 'Fruit eaten' } }, series: [{ name: 'Jane', data: [1, 0, 4] }, { name: 'John', data: [5, 7, 3] }] }); });</script> </head> <body> <div id="container" style="width:100%; height:400px;"></div> </body> </html>
works fine. 工作正常。 Just removed the double closing brackets from closing html tag. 刚刚从关闭html标记中删除了双括号。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.