Vue3报错Cannot read properties of undefined (reading ‘globalProperties‘)
Vue3全局绑定Cannot read properties of undefined (reading 'globalProperties')
·
将默认的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')
更多推荐
已为社区贡献1条内容
所有评论(0)