在我的朋友的帮助下,我们提出了该解决方案,并按照我们的预期工作:
分享这一点:
this.subscribe = firebase
.firestore()
.collection('orders')
.where('restaurant_code', '==', this.state.restaurantCode)
.orderBy('timestamp', 'desc')
.onSnapshot((docSnapshot) => {
const dataSource = [];
docSnapshot.forEach((doc) => {
dataSource.push(doc.data());
});
if (this._isMounted) {
this.setState({ dataSource });
}
});
我也面临着同样的问题,就我而言,以下方式对我有用
firebase.initializeApp(firebaseConfig);
var db = firebase.firestore();
var docRef = db.collection('Users').doc('001').collection('Data').orderBy("Date", "desc")
...