prepare use of vue for game/replay
This commit is contained in:
parent
343263be6c
commit
8e7aa7d453
7 changed files with 156 additions and 43 deletions
26
public/views/Game.vue.js
Normal file
26
public/views/Game.vue.js
Normal 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
|
||||
},
|
||||
},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue