Vue uses created hooks to call methods in methods?

The

code is as follows:
new Vue ({
methods: {

post: function (url, data) {
  $.ajax({
    type: "POST",
    url: "...."+url+".ashx",
    data:data,          
 })
}

},
created () {

this.post("XXX", "XXX").done(function(res){
  console.log(res)
})

}
})
error: this.post (.) Is undefined
doesn"t know enough about vue. Why can"t we call the post method of methods here? because how to write to get the post method, ask for expert advice

Mar.31,2021

this.post can be called in created. Is there a problem with your done

vue component life cycle
clipboard.png

attached

there is no return value for post () in your code, that is, undefined, so calling done () reported an error.


new Vue({
    methods: {
        
        post: function (url, data) {
          return new Promise(function(resolve, reject) {
              $.ajax({
                type: 'POST',
                url: '....'+url+'.ashx',
                data:data,
                success: function(res) {
                    resolve(res);
                }         
             })
          });
        }
    },
    created () {
        this.post('XXX', 'XXX').then(function(res){
          console.log(res)
        });
    }
});
Menu