此处的代码用于从Google Maps上的某个地方获取评论,并将其显示在Vue应用上。
rViewData: function () {
var self= this;
var request = {
placeId: this.placeId,
fields: ['review']
};
var service = new google.maps.places.PlacesService(document.createElement('div'));
service.getDetails(request, callback);
function callback(results, status) {
if (status == google.maps.places.PlacesServiceStatus.OK) {
console.log(results.reviews.length)
console.log(results.reviews)
for await(let o of results.reviews) {
const name = o.author_name
self.reviews.push(name)
console.log(name)
}
}
}
现在,我只是在伪装此代码以使其工作;使用self,显式编写回调。.
如何正确将其写为箭头函数?