У меня есть обычный компонент с одним файлом, который имеет как вычисляемое свойство, так и несколько методов:
<template>...</template>
<script>
...
export default {
props: ['matches'],
data: function() {...} // No problem with these
computed: {
formattedMatches: function () {
let formatted = [];
this.matches.forEach(function($match, $i, $arr) {
formatted[$i] = $match[0];
};
});
return formatted;
}
...
methods: {
getData: function() {
return this.formattedMatches();
},
...
}
}
<script>
Когда я пытаюсь получить доступ к this.formattedMatches()
из метода, я получаю [Vue warn]: Error in render: "TypeError: this.formattedMatches is not a function"
.
Каков правильный способ добиться того, чего я хочу? Заранее спасибо.
this.formattedMatches()
наthis.formattedMatches
. - person Sphinx   schedule 19.09.2018