我正在用Vue&Firebase创建一个电子商务。尝试从当前登录用户添加一些购物车信息。奇怪的是,信息在第一时间就完美地保存了下来。当我尝试再次添加一些时。那个有效的方法并显示出此错误。
“未捕获的FirebaseError:函数DocumentReference.set()用无效数据调用。不支持的字段值:未定义”
所以我必须刷新该页面。然后它再次工作。我不明白问题出在哪里。
注意:如果我尝试添加其他值而不是购物车。然后就可以了。
checkout(){
var db = firebase.firestore();
var user = firebase.auth().currentUser;
db.collection("orders").add({
user_id:user.uid,
cart:this.cart
})
console.log(this.cart);
this.$store.commit('emptyCart')
this.$router.push({ name: 'Home'})
}