gpt4 book ai didi

javascript - HTML 脚本不加载 JavaScript 文件

转载 作者:行者123 更新时间:2023-11-29 12:58:34 25 4
gpt4 key购买 nike

我正在尝试在我的 iOS xcode 项目的 UIWebview 中显示饼图,因为我将 jqplot 与 HTML、CSS 和 JavaScript 结合使用,我面临的问题是 JavaScript 文件“devicepiechart.js”正在从 html 加载。

<!DOCTYPE html>

<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="jquery.jqplot.css" />
<script>
function load()
{
alert("I am an loading scripts!");
}
</script>

<script src="devicepiechart.js"></script>
</head>
<body onload= "load()">
</body>
</html>

load() 函数警报正确显示,没有任何问题。我可以检测到我的 .js 文件没有加载,因为我的 .js 文件中也有 alert("string"); 函数用于调试。

已更新 devicepiechart.js,我希望外部 .js 文件不会有任何错误,因为我有这个 http://www.jqplot.com/tests/pie-donut-charts.php 的源代码

$(document).ready(function()
{
alert("good");
var data = [
['Heavy Industry', 12],['Retail', 9], ['Light Industry', 14],
['Out of home', 16],['Commuting', 7], ['Orientation', 9]
];
var plot1 = jQuery.jqplot ('chart1', [data],
{
seriesDefaults: {
// Make this a pie chart.
renderer: jQuery.jqplot.PieRenderer,
rendererOptions: {
// Put data labels on the pie slices.
// By default, labels show the percentage of the slice.
showDataLabels: true
}
},
legend: { show:true, location: 'e' }
}
);
});

最佳答案

在其他 js 加载之前包含 jquery

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>

关于javascript - HTML 脚本不加载 JavaScript 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20369967/

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