Cannot read property'$Message' of undefined

use the iview component Message
to make a login request using axios, and display the error message according to the returned status code

  this.$axios.post("http://wx.simplesay.xin/user/login", {
    email: this.formLogin["email"],
    password: this.formLogin["password"]
  }).then(function (response) {
    if (response.data.code === 10001) {
      this.$Message.info("")
    } else {
      console.log(response.data)
    }
  })
  

but this will cause an error
if I create a method

ok () {
  this.$Message.info("Clicked ok")
},

if you use it in a Model component, you will not report an error. What is the reason?
< Modal

    v-model="model_login"
    title="Common Modal dialog box title"
    :closable="false"
    :mask-closable="false"
    @on-ok="ok"
    @on-cancel="cancel">
Aug.20,2021

ordinary functions and arrow functions learn


context problem, change it to the following

this.$axios.post('http://wx.simplesay.xin/user/login', {
    email: this.formLogin['email'],
    password: this.formLogin['password']
  }).then((response) => {
    if (response.data.code === 10001) {
      this.$Message.info('')
    } else {
      console.log(response.data)
    }
  })
Menu