Google 地图 API VueJS 网络应用中的弃用错误:utc_offset 已于 2019 年 11 月弃用,并将于 2020 年 11 月关闭
Google Maps API Deprecation Error in VueJS web app: utc_offset is deprecated as of November 2019 and will be turned off in November 2020
我目前在我的 VueJS 网络应用程序中收到以下错误。
utc_offset is deprecated as of November 2019 and will be turned off in
November 2020. Use utc_offset_minutes instead.
根据Google Maps API documentation:
The Places fields opening_hours.open_now and utc_offset are deprecated
as of November 20, 2019, and will be turned off on November 20, 2020.
These fields are deprecated ONLY in the Places Library, Maps
JavaScript API. This guide shows you how to update your code to stop
using these fields.
唯一的问题是,我绝对不会直接在我的 Vue 应用程序中的任何地方使用 utc_offset。我通过在我的应用程序中对单词 "utc_offset" 进行全局查找来验证这一点。我也不记得访问过那个特定的 属性.
如果我没有使用 属性 为什么会收到此弃用警告?
下面是我的堆栈跟踪:
以下代码片段显示了 clearAllCardsAndFilters
方法的作用。
methods: {
clearAllCardsAndFilters() {
this.clearActiveCardListingId();
this.clearFilterCards();
},
clearActiveCardListingId() {
this.$store.commit('clearActiveCardListingId');
},
以下代码片段显示了 Vuex 中的 clearActiveCardListingId
突变的作用。它只是将 Vuex 中的 activeCardListingId
属性 设置为 null
。
clearActiveCardListingId(state) {
state.activeCardListingId = null;
},
我在使用 Google 地点 API 时未指定任何字段。一旦您以下列方式指定字段,此弃用警告就会消失。确保避免将 "utc_offset" 指定为字段,否则消息将返回。
new google.maps.places.PlacesService(attrContainer).getDetails({
placeId: '...',
fields: ['opening_hours','utc_offset_minutes'],
}, function (place, status) {
if (status !== 'OK') return; // something went wrong
const isOpenAtTime = place.opening_hours.isOpen(new Date('December 17, 2020 03:24:00'));
if (isOpenAtTime) {
// We know it's open.
}
const isOpenNow = place.opening_hours.isOpen();
if (isOpenNow) {
// We know it's open.
}
});
如果您使用的是VUE2-google-maps,那么您可以通过以下方式使用google地图组件:
<GmapAutocomplete
@place_changed="setPlace"
:options="{fields: ['geometry', 'formatted_address', 'address_components']}">
</GmapAutocomplete>
没有 :options
它对我有用
:fields="['geometry', 'opening_hours', 'business_status']"
我目前在我的 VueJS 网络应用程序中收到以下错误。
utc_offset is deprecated as of November 2019 and will be turned off in November 2020. Use utc_offset_minutes instead.
根据Google Maps API documentation:
The Places fields opening_hours.open_now and utc_offset are deprecated as of November 20, 2019, and will be turned off on November 20, 2020. These fields are deprecated ONLY in the Places Library, Maps JavaScript API. This guide shows you how to update your code to stop using these fields.
唯一的问题是,我绝对不会直接在我的 Vue 应用程序中的任何地方使用 utc_offset。我通过在我的应用程序中对单词 "utc_offset" 进行全局查找来验证这一点。我也不记得访问过那个特定的 属性.
如果我没有使用 属性 为什么会收到此弃用警告?
下面是我的堆栈跟踪:
以下代码片段显示了 clearAllCardsAndFilters
方法的作用。
methods: {
clearAllCardsAndFilters() {
this.clearActiveCardListingId();
this.clearFilterCards();
},
clearActiveCardListingId() {
this.$store.commit('clearActiveCardListingId');
},
以下代码片段显示了 Vuex 中的 clearActiveCardListingId
突变的作用。它只是将 Vuex 中的 activeCardListingId
属性 设置为 null
。
clearActiveCardListingId(state) {
state.activeCardListingId = null;
},
我在使用 Google 地点 API 时未指定任何字段。一旦您以下列方式指定字段,此弃用警告就会消失。确保避免将 "utc_offset" 指定为字段,否则消息将返回。
new google.maps.places.PlacesService(attrContainer).getDetails({
placeId: '...',
fields: ['opening_hours','utc_offset_minutes'],
}, function (place, status) {
if (status !== 'OK') return; // something went wrong
const isOpenAtTime = place.opening_hours.isOpen(new Date('December 17, 2020 03:24:00'));
if (isOpenAtTime) {
// We know it's open.
}
const isOpenNow = place.opening_hours.isOpen();
if (isOpenNow) {
// We know it's open.
}
});
如果您使用的是VUE2-google-maps,那么您可以通过以下方式使用google地图组件:
<GmapAutocomplete
@place_changed="setPlace"
:options="{fields: ['geometry', 'formatted_address', 'address_components']}">
</GmapAutocomplete>
没有 :options
它对我有用:fields="['geometry', 'opening_hours', 'business_status']"