如何解决意外的令牌,预期为“”?
我正在处理日历,并尝试使用react-native-calendar-events库将事件添加到本机iOS日历中,但是似乎收到一条错误消息,说createCalendarEvent()声明缺少“(” 。我不确定我到底在哪里想念它。
async function addToCalendar(event) {
try {
const startDate =
Platform.OS === "ios"
? format(parse(event.StartDateLocal))
: parse(event.StartDateLocal);
const endDate =
Platform.OS === "ios"
? format(parse(event.EndDateLocal))
: parse(event.EndDateLocal);
const allEvents = await RNCalendarEvents.fetchAllEvents(startDate,endDate);
const calendarEvent = allEvents.find(e => e.title === event.Title);
if (calendarEvent) {
alert("You have already added this event to your calendar.");
} else {
const title = event.Title;
const {
Location: {
AddressLine1: address,City: city,StateAbbreviation: state,PostalCode: zip
}
} = event;
const location = `${address},${city},${state},${zip}`;
const settings = {
location,startDate,endDate
};
RNCalendarEvents.saveEvent(title,settings)
.then(() => {
alert("Event Saved");
})
.catch(rejectionReason => {
console.log(rejectionReason);
alert("Oops! Something has gone wrong.");
});
}
} catch (e) {
alert(e.message);
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。