Coming from Knockout.js, where observables are easily created by defining them, I'm curious if there's a similar approach in Vue.js.
let vm = {
someOtherVar: ko.observable(7),
entries: ko.observableArray()
};
function addServerDataToEntries(data) {
data.myComputed = ko.pureComputed(() => vm.someOtherVar() + data.bla);
vm.entries.push(data);
}
addServerDataToEntries({ bla: 1 });
In my current Vue.js project, I am fetching a list of objects from the server. For each object in the list, I need to add a computed property that can be used in a v-if
binding. How can I go about achieving this in Vue.js?