I'm new on Vue framework and I'm trying to make some composition examples using components, but I having a problem when i try to execute the code:
"Property or method "icons" is not defined on the instance but referenced during render. Make sure that this property is reactive"
In template I have:
<template>
<div>
<h1>Welcome a la nueva pagina</h1>
<div v-for="icon in icons">{{ icon }}</div>
</div>
</template>
In a file called Footer.ts I have the followind code:
import {Component, Vue} from "vue-property-decorator";
import Template from './Footer.vue';
@Component({
mixins: [Template]
})
export default class Footer extends Vue {
public icons!: string[];
constructor() {
super();
this.icons = [
'fab fa-facebook',
'fab fa-twitter',
'fab fa-google-plus',
'fab fa-linkedin',
'fab fa-instagram'
];
console.log('Footer renderizado');
this.icons.map((icon) => console.log(icon));
}
}
Finally on App.vue I have:
<template>
<div>
<h1>Pagina principal</h1>
<footer></footer>
</div>
</template>
<script lang="ts">
import {Component, Vue} from 'vue-property-decorator';
import Footer from '@/component/Footer';
@Component({
components: {
Footer
}
})
export default class App extends Vue {
mounted() {
console.log("ensamblado terminado");
}
}
</script>
In case of Footer.ts, constructor is never call.
Thanks