问题描述
我正在使用这个html代码,我试图在我的手柄文件上实现。虽然它在html / javascript文件上工作,但我无法使它在句柄文件中工作。
当我在车把中使用它时,出现此错误:Uncaught TypeError:$(...)。geocomplete不是函数
我把代码放到main.handlebar中:
< script src =http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery .min.js>< /脚本>
< script src =js / jquery.geocomplete.js>< / script>
< script language =javascript>
$(function(){
$(#geocomplete)。geocomplete()。bind(geocode:result,function(event,result){
$ .log(Result:+ result.formatted_address);
})
.bind(geocode:error,function(event,status){
$ .log (错误:+状态);
})
.bind(geocode:multiple,function(event,results){
$ .log(Multiple:+ results。长度+找到的结果);
});
});
< / script>
并且它不能识别位于js / jquery.geocomplete.js中的.geocomplete()方法
它可以在HTML文件中识别它。
Google Maps JavaScript API的API密钥,并将您的API密钥设置为 < script src =https://maps.googleapis的.com /地图/ API / jskey = API_KEY_HERE&安培;库=地方>< /脚本>
I am using this html code that I am trying to implement onto my handlebar file. While it works on the html/javascript file, I can't get it to work in the handlebar file.
When I use it in the handlebar, I get this error : Uncaught TypeError: $(...).geocomplete is not a function
I am putting the code into main.handlebar:
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script src="js/jquery.geocomplete.js"></script>
<script language = "javascript">
$(function(){
$("#geocomplete").geocomplete().bind("geocode:result", function(event, result){
$.log("Result: " + result.formatted_address);
})
.bind("geocode:error", function(event, status){
$.log("ERROR: " + status);
})
.bind("geocode:multiple", function(event, results){
$.log("Multiple: " + results.length + " results found");
});
});
</script>
and it is not recognizing .geocomplete() method that is in js/jquery.geocomplete.js
It recognizes it in a html file though.
Get your API key for Google Maps JavaScript API and place your API key like
<script src="https://maps.googleapis.com/maps/api/jskey=API_KEY_HERE&libraries=places"></script>
这篇关于使用手柄我得到这个错误:Uncaught TypeError:$(...)。geocomplete不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!