Why this in axios callback function is undifine?

this.$axios.get("./data.json").then(function(result){
      console.log(this) //undefine
    })

with regard to the problem of pointing to the axios callback function this, most articles on the Internet only recommend using the arrow function instead of the ordinary function to solve the problem, but they do not explain why this points to undefine, and should point to window, in my understanding, because the caller of this anonymous callback function must be the window object, but the result is that undefined, feels that my understanding of this pointing has collapsed again. -. -

Feb.13,2022

this.$axios.get("./data.json").then(result => {
      console.log(this) //undefine
    })

write this: in the callback of axios, this no longer points to vue and uses the arrow function () = > {}


  1. the this inside the self-executing function points to window
  2. When the
  3. function executes, see if there is a "." in front of the function. If so, this is "." Previous instance
  4. When the
  5. tag binds an event, this points to the current tag element
  6. the this in the constructor points to the instance of the call

to sum up:
I think your this is supposed to point to window. Why does undefined, kneel and wait for Daniel


should be the code is strict mode of the 'use strict'' bar.

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-1e89f26-f9d.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-1e89f26-f9d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?