将默认的main.js的内容

import { createApp } from 'vue'
import App from './App.vue'

createApp(App).mount('#app')

更改为如下再使用全局绑定

import { createApp } from 'vue'
import App from './App.vue'


// 为避免Cannot read properties of undefined (reading 'globalProperties')
// 需要将crateApp和mount分开,将全局绑定内容夹在中间
const app = createApp(App)

import axios from 'axios'
axios.defaults.baseURL='http://localhost:8088'
app.config.globalProperties.$http=axios

app.mount('#app')



Logo

前往低代码交流专区

更多推荐