在vue2中,可以通过Vue(import Vue from 'vue' )来挂载axios和element,在vue3中通过过Vue来全局注册这种方式似乎变得麻烦起来
一、 安装
1.1 安装axios
cnpm i --save axios
1.2 安装element-ui
npm install element-plus --save
二、 挂载axios和注册element组件(main.js)
import { createApp } from 'vue'
import axios from 'axios'
import App from './App.vue'
import { ElButton } from 'element-plus'
const app=createApp(App)
app.config.globalProperties.$axios=axios
app.use(ElButton).mount('#app')
2.1 挂载axios
import { createApp } from 'vue'
import axios from 'axios'
import App from './App.vue'
const app=createApp(App)
app.config.globalProperties.$axios=axios
2.2 注册element-ui组件(以ElButton为例)
import { createApp } from 'vue'
import App from './App.vue'
import { ElButton } from 'element-plus'
createApp(App).use(ElButton).mount('#app')
|