jquery 未捕获的类型错误:$(...).googlePlaces不是函数

wr98u20j  于 2023-10-17  发布在  jQuery
关注(0)|答案(1)|浏览(92)
<link rel="stylesheet" href="https://cdn.rawgit.com/stevenmonson/googleReviews/master/google-places.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/gh/stevenmonson/googleReviews@6e8f0d794393ec657dab69eb1421f3a60add23ef/google-places.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?v=3.exp&key=API_KEY&signed_in=true&libraries=places"></script>

<div id="google-reviews"> </div>

jQuery(document).ready(function() {
        $("#google-reviews").googlePlaces({
            placeId: '[Place ID]', 
            render: ['reviews'],
            min-rating: 4,
            max-rows: 5
        });
    });

console.log()一直显示类型错误,google places不是一个函数。
继续更改cdn版本和源链接来修复错误,但控制台日志仍然显示相同的错误。

dojqjjoe

dojqjjoe1#

按以下顺序使用脚本:

<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/google-places.js"></script>
<script src="https://maps.googleapis.com/maps/api/js?callback=Function.prototype&libraries=places&key=YOUR_KEY"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/google-places.css">

在Google Cloud/Maps API授权站点上进行测试

相关问题