gpt4 book ai didi

javascript - Chartist 未定义错误

转载 作者:塔克拉玛干 更新时间:2023-11-02 23:03:29 25 4
gpt4 key购买 nike

我正在尝试使用 Chartist.js为我的网站创建图表和图形的框架。但出于某种原因,我不断收到错误消息“Chartist is not defined”

我不知道如何解决这个错误。请看下面的代码:

<!DOCTYPE html>
<html>
<head>
<script src="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
<link href="https//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Oxygen:300' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Chartist.js - Simple line chart</title>
<script>
// THIS IS WHERE THE ERROR OCCURS
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[2, 3, 2, 4, 5],
[0, 2.5, 3, 2, 3],
[1, 2, 2.5, 3.5, 4]
]
}, {
width: 500,
height: 300
});

</script>
</head>

<body>
<div class="ct-chart"></div>

</body>
</html>

有谁知道我做错了什么?提前致谢。

最佳答案

将您的脚本移至页脚:

<!DOCTYPE html>
<html>
<head>

<link href="https//cdn.jsdelivr.net/chartist.js/latest/chartist.min.css" rel="stylesheet" type="text/css" />
<link href='http://fonts.googleapis.com/css?family=Oxygen:300' rel='stylesheet' type='text/css'>
<meta charset="utf-8">
<title>Chartist.js - Simple line chart</title>

</head>

<body>
<div class="ct-chart"></div>
<script src="https://cdn.jsdelivr.net/chartist.js/latest/chartist.min.js"></script>
<script>
// THIS IS WHERE THE ERROR OCCURS
new Chartist.Line('.ct-chart', {
labels: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri'],
series: [
[2, 3, 2, 4, 5],
[0, 2.5, 3, 2, 3],
[1, 2, 2.5, 3.5, 4]
]
}, {
width: 500,
height: 300
});

</script>
</body>

</html>

http://plnkr.co/edit/3sAdiBJaaue3x9kgBRZw?p=preview

它的工作就像一个魅力:)

关于javascript - Chartist 未定义错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30455764/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com