I have an arrangement of objects called materials and when I try to put it in a VueJS component and then show it I get an error:
<script>
var app = new Vue({
el: '#app',
data: {
materias: []
},
created(){
var _this = this;
var url = "src/xmls/test.xlsx";
var oReq = new XMLHttpRequest();
oReq.open("GET", url, true);
oReq.responseType = "arraybuffer";
oReq.onload = function(e) {
var arraybuffer = oReq.response;
/* convirtiendo data a binary string */
var data = new Uint8Array(arraybuffer);
var arr = new Array();
for (var i = 0; i != data.length; ++i) arr[i] = String.fromCharCode(data[i]);
var bstr = arr.join("");
/* Cargando XLSX */
var workbook = XLSX.read(bstr, { type: "binary" });
/* DO SOMETHING WITH workbook HERE */
var first_sheet_name = workbook.SheetNames[0];
/* Get worksheet */
var worksheet = workbook.Sheets[first_sheet_name];
materias = XLSX.utils.sheet_to_json(worksheet, { raw: true });
_this = materias;
};
oReq.send();
}
})
</script>
I show it in this way in my template section:
<template>
<div id="app">
<div class="col-xs-12">
<h1 class="text-center">Materias</h1>
</div>
<div class="row">
<div class="col-md-6 col-md-offset-3">
<ul class="list-group">
<li class="list-group-item text-center" v-for="(materia,$index) in materias">
<span>{{ $index }} - Nombre: {{ materia.Curso }}</span>
</li>
</ul>
</div>
</div>
With the corrections that were indicated below, I solved a couple of errors but the background one, which is that the component receives the fix, persists:
Looking at the console effectively the material property is not defined in the component, so I do not know why my arrangement does not enter the component: