Error by adding an value to an array, but I don't know how to solve it! #10879
Unanswered
nkamp
asked this question in
Help/Questions
Replies: 1 comment
-
This seems to have nothing to do with vue, but a problem you encountered using typescript. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have todo some maintenance to a Vue project. From the backend records are send to the front-end and one field is picked to put the unique values in an Array to fill a dropdown with it.
`
...
const alleOvertredingen = ref<Array>([]);
const registrators = computed(() =>
unique(
alleOvertredingen.value .map((overtreding) => overtreding.handhavingDoor)
.concat(medewerker.value?.organisatie.naam)
).sort((a, b) => a.localeCompare(b))
);
...
`
The error which is returned:
If I replace
medewerker.value?.organisatie.naam
by a String like "Some value", than this value is added without error, so the idea is working in my opinion.Or if I define a variable with let and in a watch() I add console.log, than the value is shown:
`
let medewerkerOrg = medewerker.value?.organisatie.naam;
watch(
console.log("random tekst: " + medewerkerOrg); // value is shown
...
`
If I define a 'const' instead of let, than there is still an issue, 'medewerkerOrg undefined'.
Beta Was this translation helpful? Give feedback.
All reactions