[Vuejs]-Error when trying to add created method in Vue component

1👍

The created lifecyle method goes within the body of the Vue component itself, not outside. I mean:

export default {
    props: ["messages"],
    created() {
        $(".chat-log").scrollTop($(".chat-log").prop('scrollHeight'));
    }
 }

Vue.js Lifecycle

1👍

Your created(){} method should be encapsulated within your export default {} block.

In other words, change your code this:

export default {

  props: ["messages"],

  created() {
   $(".chat-log").scrollTop($(".chat-log").prop('scrollHeight'));
  }

},
👤samayo

Leave a comment