The data is on firebase, and I want to show only 1 object with [objectNumber] see {{ligler[1].name}}
in the template, but when I do this it works but I get errors:
- Error when rendering component
- Uncaught TypeError: Cannot read property 'name' of undefined
I think, the problem is that the data loaded before the component.
When I use v-for, it show the name off all objects without errors, but I only want to show one object.
The template looks like:
<template>
<div id="app">
<h1>{{ligler[1].name}}</h1>
</div>
</template>
the script:
<script>
import Firebase from 'firebase'
let config = {
apiKey: "xxxxxxxxxx",
authDomain: "xxxxxxxxxx",
databaseURL: "https://xxxxxxxxxx.firebaseio.com"
}
let app = Firebase.initializeApp(config);
let db = app.database();
let ligRef = db.ref('ligler');
export default {
name: 'app',
firebase: {
ligler: ligRef
}
}
</script>
I tried to add v-if to the h1, but that doesn't work.
How can I fix this errors?