【发布时间】:2017-06-18 19:09:39
【问题描述】:
我正在尝试使用 Google Maps API,但我的 HTML 找不到我的 javascript 文件。查看开发工具的网络选项卡,它甚至没有尝试获取 script.js 文件。没有 404 或 200 响应。发现所有其他脚本都非常好。
文件结构:
/css
- styles.css
/js
- script.js
index.html
index.html 脚本:
<script async type="text/javascript"
src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.4.2/knockout-min.js"></script>
<script
src="https://code.jquery.com/jquery-3.2.1.min.js"
integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4="
crossorigin="anonymous"></script>
<script async type="text/javascript"
src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<script async type="text/javascript"
href="js/script.js"></script>
<script async defer type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?v=3&callback=initMap"></script>
script.js:
var map;
function initMap() {
// Constructor creates new map
map = new google.maps.Map(document.getElementById('map'), {
center: {lat: 40, lng: -70},
zoom: 25
});
}
【问题讨论】:
-
按
Ctrl+F5
标签: javascript html