Raxit Sheth
Raxit Sheth

Reputation: 2601

Vue.js - calling data() inside mounted() throws error

mounted () {
  this.data(); // or only data();
}

message: "this.data is not a function"

What is the best way to call data() after page load?

Upvotes: 0

Views: 110

Answers (1)

Hung Nguyen
Hung Nguyen

Reputation: 1156

Maybe i don't know this.data() function, but just use data like sample below:

<script>
export default {
  data() {
    return {
      foo: 'bar',
    }
  },
  mounted() {
    console.log(this.foo) // will print "bar"
  },
}
</script>

Upvotes: 1

Related Questions