我是新來的HTML。過去5個小時我一直在調試我的代碼,我無法弄清楚它有什麼問題。我引用一個只有1個方法的包,即get_country。我使用的包的鏈接在這裏。 https://github.com/nickewing/line-reader和https://github.com/totemstech/country-reverse-geocoding我的html代碼有什麼問題?
<html>
<head>
<script type="text/javascript">
function a() {
var lineReader = require('line-reader');
lineReader.eachLine(‘Location.txt', function(line, last) {
var b= line.split(「,」,2)
var lat= parseInt(b[0])
var lng= parseInt(b[1])
var crg = require('country-reverse-geocoding').country_reverse_geocoding();
var country = crg.get_country(lat, lng);
console.log(country.name); //
if (/* done */) {
return false; // stop reading
}
});
}
</script>
</head>
<body>
<button type="button" onclick=「a()>Click run reverse geocoder</button>
</body>
</html>
任何機會,它是引號本身?我發現一個答案找到了你缺少的引用,但是'line.split'周圍的雙引號看起來不是標準的雙引號 - 可能轉換爲單引號會有所幫助。 –
現在我得到一個錯誤,說Uncaught ReferenceError:a沒有定義hii.html:27 onclick你知道什麼可能導致這種情況嗎? –