【发布时间】:2019-09-26 21:40:45
【问题描述】:
我在const{manifest}=Expo.Constants 中的Constants 收到一个错误,并显示一个错误,因为未定义不是一个对象。我无法得到它。谁能帮我消除这个错误。
我正在尝试在我的计算机上运行的 API 和我在手机上进行调试时建立连接。无论 IP 地址是什么,它都应该连接。
import moment from 'moment';
import Expo from 'expo';
const{ manifest} = Expo.Constants;
const api = manifest.packagerOpts.dev
? manifest.debuggerHost.split(':').shift().concat(':3000')
: 'productionurl.com'
const url ='http://localhost:3000';
export function getEvents(){
return fetch(url)
.then(response => response.json())
.then(events => events.map( e =>({...e})));
}
export function formatDateTime(dateString){
const parsed = moment(new Date(dateString));
if(!parsed.isValid()){
return dateString;
}
return parsed.format('H A on DD MMM YYYY');
}
export function formatDate(dateString){
const parsed = moment(new Date(dateString));
if(!parsed.isValid()){
return dateString;
}
return parsed.format('DD MMM YYYY');
}
export function getCountdownParts(eventDate){
const duration = moment.duration(moment(new Date(eventDate)).diff(new Date()));
return{
days:parseInt(duration.as('days')),
};
}
从
db.json文件中显示在我的模拟器上的预期事件,但是 我收到未定义的错误。
【问题讨论】:
标签: react-native module momentjs expo