How to get a vue instance in the axios.js of the axios configuration of the vue project?

how to get a vue instance in the axios.js of the axios configuration of the vue project?

In the

vue project, I can get the vue object by this in the .vue file, but this.XX cannot get the vue instance in the .js file. What should I do? I want to use the this.* method

.

I want to use the this.$createElement of the vue instance in * .js, so I did this

this is what I wrote below, which solves my problem, but is it elegant?

import Vue from "vue"
import App from "./App.vue"

new Vue({
  router,
  store,
  render: h => h(App),
  created() {
    Vue.prototype.$createElementNode = this.$createElement
  }
}).$mount("-sharpapp")

inside the axios.js file:

import { MessageBox } from "element-ui";
import Vue from "vue"

const h = Vue.prototype.$createElementNode
MessageBox({
  title: "",
  // message: message,
  message: h("div", null, [
    h("el-input", {
      props: {
        value: 1234,
      }
    }),
    h("el-input", {
      props: {
        value: 1234,
      }
    })
  ]),
  showCancelButton: true,
  confirmButtonText: "",
  cancelButtonText: ""
})
Jun.22,2021

 var app = new Vue({
        el:"-sharpapp",
        data :{
            message: 'Hello Vue!',
            goods:[]

        },
     created(){        axios.get('/goods/homeGoods').then(function(response) {
                this.goods=response.data
                console.log(this.goods.catelogGoods1)
                // console.log(response);
                //bind(this)Vuedata
            }.bind(this))

        }}
    )

all I can think of is your way of writing. External files need to call instances in the component and can only be saved by global references. However, it is easy to write memory leaks. It is really not beautiful

Menu