在React-Redux中调用一个函数时,我得到的不是buildLngLat函数上的函数错误。有人可以解释为什么我收到此错误。它过去曾经有过作用。
const pickUpArr = {
latitude: store().home.bookingDetails.pickUp.latitude,
longitude: store().home.bookingDetails.pickUp.longitude
};
const dropOffArr = {
latitude: store().home.bookingDetails.dropOff.latitude,
longitude: store().home.bookingDetails.dropOff.longitude
};
buildLngLat = (position) => {
return `${position.latitude},${position.longitude}`
};
const origin = this.buildLngLat(pickUpArr);
const destination = this.buildLngLat(dropOffArr);
错误输出:
答案 0 :(得分:0)
如果您要调用独立函数,则无需通过this
。只需直接调用即可:
const buildLngLat = (position) => {
return `${position.latitude},${position.longitude}`
};
const origin = buildLngLat(pickUpArr);
const destination = buildLngLat(dropOffArr);