Answer the question
In order to leave comments, you need to log in
How to access a component property from a function?
The VueJS component has a "content" property. I need to access this property in a foreach loop (an example with output to the console is purely abstract).
Tried this.content but there is no this inside the forEach loop function.
How can I access a property (prop) of a component from a function?
computed: {
processedHtml: function () {
this.dropdown.forEach(function(item, name){
// Here I'm trying to get access to property "content" of my component
window.console.log(this.content);
})
return {...}
}
}
Answer the question
In order to leave comments, you need to log in
// ...
computed: {
processedHtml() {
this.dropdown.forEach((item, name) => {
window.console.log(this.content);
})
}
}
// ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question