prepare use of vue for game/replay

This commit is contained in:
Zutatensuppe 2021-05-13 16:58:21 +02:00
parent 343263be6c
commit 8e7aa7d453
7 changed files with 156 additions and 43 deletions

26
public/views/Game.vue.js Normal file
View file

@ -0,0 +1,26 @@
"use strict"
export default {
name: 'game',
template: `<div>{{gameData}}</div>`,
data() {
return {
gameData: null,
}
},
created() {
this.$watch(
() => this.$route.params,
() => { this.fetchData() },
{ immediate: true }
)
},
methods: {
async fetchData() {
this.gameData = null
const res = await fetch(`/api/game-data/${this.$route.params.id}`)
const json = await res.json()
this.gameData = json
},
},
}