R
R
robert_ford2020-11-08 15:23:49
Vue.js
robert_ford, 2020-11-08 15:23:49

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

1 answer(s)
K
Klein Maximus, 2020-11-08
@robert_ford

// ...
computed: {
  processedHtml() {
    this.dropdown.forEach((item, name) => {
      window.console.log(this.content);
    })
  }
}
// ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question