I use Firebase to store the database, and have a object currentWeek with a value off the current week.
I want to store the value of this object in a variable to call it.
Currently I'm using this to get the current week, but I want to get the current week from the database:
<template>
<div id="app">
<div v-if="ligler[1]">
<h3>{{ligler[1].weeks[currentWeek].day}}</h3>
</div>
</template>
<script>
import Firebase from 'firebase'
let config = {
apiKey: "xxxx",
authDomain: "xxx.firebaseapp.com",
databaseURL: "https://xxx.firebaseio.com"
}
let app = Firebase.initializeApp(config);
let db = app.database();
let ligRef = db.ref('ligler');
export default {
name: 'app',
firebase: {
ligler: ligRef
},
data() {
return {
currentWeek: 18
}
}
}
</script>
I tried this, but it doesn't work:
data() {
return {
currentWeek: ligler[1].currentWeek
}
}
The database look like:
How can I assign the value of currentWeek to a variable in vue.js? To use it in the code as [currentWeek]
:
<h3>{{ligler[1].weeks[currentWeek].day}}</h3>