calling a method from created hook in vuejs component

First change your hook method to this :

methods: {
  mymethod(x){alert(x);}
}

Then, also change the called methods inside the created hook function. It must look like this :

created(){
  this.mymethod('success');
}

Then you are done!


When defining Vue methods, life-cycle methods, computed properties, ... it's better not using arrow functions, because in that way you are overriding the this pushed by Vue itself. Try this:

export default {
  methods: {
    mymethod (x) { alert(x) },
  },
  created () {
    this.mymethod('success');
  },
  ...
}

You have used the arrow function in created hook. Try using

created: function {
   this.mymethod('success');
},

if you check the vue.js documentation that also clearly states

Don’t use arrow functions on an options property or callback, such as created: () => console.log(this.a) or vm.$watch('a', newValue => this.myMethod()). Since arrow functions are bound to the parent context, this will not be the Vue instance as you’d expect, often resulting in errors such as Uncaught TypeError: Cannot read property of undefined or Uncaught TypeError: this.myMethod is not a function.