Write plug-ins to handle the problem of this delivery

I have written a global Toast plug-in for vue. One of the functions is to provide an api to pass a callback function after the toast disappears, similar to using

like this.
this.$toast({
    callback(){
        this.$router.push("/")
    }
})

but the this cannot be passed when it is implemented.
the current approach is to use a new global Vue instance via $emit/$on, but it feels like this will couple the toast plug-in with the business code. I"d like to ask how to solve this problem

Mar.18,2021
Try the

arrow function?


Please use the arrow function

  

you can add an input parameter and pass in the current instance

Menu