我正在使用Vue操作使用ArrayUnion更新保存在Firestore中文档中的“标签”数组,但出现以下错误...
错误:函数DocumentReference.update()用无效数据调用。不支持的字段值:自定义e对象(在字段标记中找到)
我正在将VUE和Vuetfiy与Vuex配合使用,并具有以下依赖性...
"dependencies": {
"es6-promise": "^4.2.5",
"firebase": "^5.7.0",
"vee-validate": "^2.1.4",
"vue": "^2.5.17",
"vue-router": "^3.0.2",
"vuetify": "^1.3.0",
"vuex": "^3.0.1"
},
并按如下所示导入Firebase .....
import firebase from 'firebase/app'
import 'firebase/auth'
import 'firebase/firestore'
const config = {
apiKey: 'xxxxxxxxxxxxxxxxxxxxxxxxxxx',
authDomain: 'xxxxxxxxxxx',
databaseURL: 'xxxxxxxxxxxxx',
projectId: 'xxxxxxxxxxx'
}
firebase.initializeApp(config)
const firestore = firebase.firestore()
const settings = {timestampsInSnapshots: true}
firestore.settings(settings)
export const db = firebase.firestore()
我的行动是...。
renameCompanyTagsInUse ({commit, getters}) {
db.collection('programs').doc(getters.programId).collection('companies').doc('FzPNtNx8ndMh5P4tHhr9').update({
tags: firebase.firestore.FieldValue.arrayUnion('TestTag')})
.catch(
(error) => {
console.log(error)
}
)
commit('setTagsChanged', {oldTag: '', newTag: ''})
commit('setLoadingButton', false)
commit('setSnackbar', {status: true, text: 'Company tag updated'})
setTimeout(() => { commit('setSnackbar', [false, '...']) }, 3000)
},
应将新标签“ TestTag”添加到公司文档ID FzPNtNx8ndMh5P4tHhr9中嵌套的数组“标签”中