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)
        });
    }
});
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3d236-2c384.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3d236-2c384.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?