Javascript 未捕获的SyntaxError:无法在模块外部使用导入语句
如果有人能帮忙,我试着使用type=“module”和type=“text/javascript”,但机器人似乎无法运行。我该怎么办 这是index.html页面,我从用户那里接收文件输入,数据将被解析为index.jsJavascript 未捕获的SyntaxError:无法在模块外部使用导入语句,javascript,html,d3.js,Javascript,Html,D3.js,如果有人能帮忙,我试着使用type=“module”和type=“text/javascript”,但机器人似乎无法运行。我该怎么办 这是index.html页面,我从用户那里接收文件输入,数据将被解析为index.js <!DOCTYPE html> <html> <head> <title>D3 Evalusation</title> <script type="text/javascript"
<!DOCTYPE html>
<html>
<head>
<title>D3 Evalusation</title>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/xlsx/0.13.5/xlsx.full.min.js"></script
<script type="module" src="https://unpkg.com/d3@5.6.0/dist/d3.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<body>
<h1 id="header">Import your Data</h1>
<div class="input_form>">
<form class="input_form" style="border:1px solid #ccc" method="POST">
<h1>Please insert your data</h1>
<label id="fname">First Name</label>
<input type="text" placeholder="John" name="name" required><br/><br/>
<label id="lname">Last Name</label>
<input type="text" placeholder="Doe" name="name" required><br/><br/>
<label id="email">Email</label>
<input type="text" placeholder="Enter email" name="email" required><br/><br/>
<label id="phone">Phone No.</label>
<input type="text" placeholder="Enter phone" name="phone" required><br/><br/>
<input type="file" id="upload_file" accept=".xls,.xlsx,.csv"/></br></br>
<label id="characteristic" >Please choose 1 characteristic to be grouped by</label>
<div id="columns"></div>
<div class="clearfix">
<a href="Homepage.html">
<button type="button" class="cancelbtn">Cancel</button></a>
<button type="submit" class="signupbtn">Sample</button>
</div>
</form>
</div>
</body>
<script type="text/javascript" src="index.js"></script>
</html>
这是D3的一个已知问题。尝试:
import * as d3 from 'd3';
d3.select(...)
这回答了你的问题吗?不,我已经在json和html中添加了类型“module”,但仍然得到相同的错误,仍然不起作用:(
import * as d3 from 'd3';
d3.select(...)