JS的新手。不知道爲什麼我在Chrome中加載此錯誤時遇到了以下錯誤。 vivagraph.js
文件與html位於同一目錄中。Uncaught ReferenceError:Viva沒有定義
<!DOCTYPE html>
<html>
<head>
<title>01. Create Graph. Vivagraph SVG tutorial.</title>
<script type="text/javascript" src="./vivagraph.js"></script>
<script type="text/javascript">
function main() {
// Step 1. We create a graph object.
var graph = Viva.Graph.graph();
// Step 2. We add nodes and edges to the graph:
graph.addLink(1, 2);
/* Note: graph.addLink() creates new nodes if they are not yet
present in the graph. Thus calling this method is equivalent to:
graph.addNode(1);
graph.addNode(2);
graph.addLink(1, 2);
*/
// Step 3. Render the graph.
var renderer = Viva.Graph.View.renderer(graph);
renderer.run();
}
</script>
<style type="text/css" media="screen">
html, body, svg { width: 100%; height: 100%;}
</style>
</head>
<body onload='main()'>
</body>
</html>
-1沒有解決OP問題。加載腳本可能不是404(除非燙髮設置不正確,在這種情況下,這個建議也無濟於事)。 – PaulProgrammer
@PaulProgrammer見編輯 – Coder