【发布时间】:2022-01-08 03:21:04
【问题描述】:
我正在使用 vis.js 时间线,我想显示来自 firestore 的日期。当我手动输入时它可以工作(查看-> this.items),但不适用于firestore(查看-> this.users)。 我正在使用 Vue 框架。
<script>
export default {
data() {
return {
users: [],
items: [
{
id: '1',
content: 'London',
group: 'Mike',
start: '2021-12-20',
end: '2022-06-19',
},
],
}
},
async fetch() {
await this.loadPlaces()
},
methods: {
async loadPlaces() {
const querySnapshot = await getDocs(collection(db, 'places'))
querySnapshot.forEach((doc) => {
this.users.push({ id: doc.id, ...doc.data() })
})
this.$store.commit('places/setPlaces', this.users)
},
},
computed: {
places() {
return this.$store.state.places.places
},
},
mounted() {
let container = document.getElementById('visualization')
let options = {
moveable: true,
}
let timeline = new vis.Timeline(container)
timeline.setOptions(options)
timeline.setGroups(this.groups)
timeline.setItems(this.items)
},
}
</script>
【问题讨论】:
标签: firebase vue.js google-cloud-firestore nuxt.js vis.js