- 本地安装Vue3.0
npm init -y
npm i @vue/cli # 安装脚手架
- 项目搭建
npx vue create project # 项目搭建,选择Vue3
- 配置vue.config.js让项目运行的时候自动打开浏览器
// vue.config.js
module.exports = {
devServer: {
open: true // 自动打开浏览器
}
}
- 安装element-plus
cnpm install element-plus --save
// main.js
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import locale from 'element-plus/es/locale/lang/zh-cn'
createApp(App).use(ElementPlus, {locale}).mount('#app')
去写菜单组件
安装axios,通过axios请求菜单数据
cnpm i -D axios
// main.js
import { createApp } from 'vue'
import App from './App.vue'
import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import locale from 'element-plus/es/locale/lang/zh-cn'
import axios from 'axios'
const app = createApp(App)
app.config.globalProperties.$http = axios
// createApp(App).use(ElementPlus, {locale}).mount('#app')
app.use(ElementPlus, {locale}).mount('#app')